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