<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class Lot extends Model
{
    protected $table      = 'lots';
    protected $connection = 'default';
    protected $fillable   = ['produit_id', 'atelier_id', 'statut', 'nb_commandes', 'notes'];

    public function produit()   { return $this->belongsTo(Produit::class, 'produit_id'); }
    public function atelier()   { return $this->belongsTo(Atelier::class, 'atelier_id'); }
    public function commandes() { return $this->belongsToMany(Commande::class, 'commande_lot', 'lot_id', 'commande_id'); }
    public function rapport()   { return $this->hasOne(Rapport::class, 'lot_id'); }
}
