2023-03-03 17:22:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
class Lignes_Commandes extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
protected $table = "Lignes_Commandes";
|
|
|
|
protected $primaryKey = "id";
|
|
|
|
public $incrementing = true;
|
|
|
|
public $timestamps = true;
|
|
|
|
protected $casts = [
|
|
|
|
'created_at' => 'timestamp',
|
|
|
|
'updated_at' => 'timestamp',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function Produit(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Produits', 'produits_id', 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Commandes(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo('App\Models\Commandes', 'commandes_id', 'id');
|
|
|
|
}
|
|
|
|
|
2023-03-10 17:43:26 +01:00
|
|
|
public function setDataTree(){
|
|
|
|
foreach($this->Produits as $produit){
|
|
|
|
$produit->setCalculatedFields();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-03 17:22:05 +01:00
|
|
|
}
|