37 lines
916 B
PHP
37 lines
916 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
|
||
|
|
class Warehouse extends Model
|
||
|
|
{
|
||
|
|
/** @use HasFactory<\Database\Factories\WarehouseFactory> */
|
||
|
|
use HasFactory;
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'code',
|
||
|
|
'name',
|
||
|
|
'address',
|
||
|
|
'description',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function inventories(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(Inventory::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function purchaseOrders(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(PurchaseOrder::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function products(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(Product::class, 'inventories')
|
||
|
|
->withPivot(['quantity', 'safety_stock', 'location'])
|
||
|
|
->withTimestamps();
|
||
|
|
}
|
||
|
|
}
|