45 lines
932 B
PHP
45 lines
932 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Warehouse extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $fillable = [
|
|
'name',
|
|
'address_line1',
|
|
'address_line2',
|
|
'postal_code',
|
|
'city',
|
|
'country_code',
|
|
];
|
|
|
|
/**
|
|
* Get the stock items for the warehouse.
|
|
*/
|
|
public function stockItems(): HasMany
|
|
{
|
|
return $this->hasMany(StockItem::class);
|
|
}
|
|
|
|
/**
|
|
* Get the stock moves from this warehouse.
|
|
*/
|
|
public function movesFrom(): HasMany
|
|
{
|
|
return $this->hasMany(StockMove::class, 'from_warehouse_id');
|
|
}
|
|
|
|
/**
|
|
* Get the stock moves to this warehouse.
|
|
*/
|
|
public function movesTo(): HasMany
|
|
{
|
|
return $this->hasMany(StockMove::class, 'to_warehouse_id');
|
|
}
|
|
}
|