* * @version 1.0.0 */ class Warehouse extends Model { protected $fillable = ['code', 'name', 'is_active', 'is_main']; protected $casts = [ 'is_active' => 'boolean', 'is_main' => 'boolean', ]; // Relaciones public function inventories() { return $this->belongsToMany(Inventory::class, 'inventory_warehouse') ->withPivot('stock', 'min_stock', 'max_stock') ->withTimestamps(); } public function inventorySerials() { return $this->hasMany(InventorySerial::class); } public function movementsFrom() { return $this->hasMany(InventoryMovement::class, 'warehouse_from_id'); } public function movementsTo() { return $this->hasMany(InventoryMovement::class, 'warehouse_to_id'); } // Scopes public function scopeActive($query) { return $query->where('is_active', true); } public function scopeMain($query) { return $query->where('is_main', true); } }