48 lines
1015 B
PHP
48 lines
1015 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class StockBatch extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'supplier_id',
|
|
'user_id',
|
|
];
|
|
|
|
/**
|
|
* Get the supplier associated with the stock batch.
|
|
*/
|
|
public function supplier(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Supplier::class, 'supplier_id')->on('vat_warehouse');
|
|
}
|
|
|
|
/**
|
|
* Get the user associated with the stock batch.
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* Get the stock entries for this batch.
|
|
*/
|
|
public function stockEntries(): HasMany
|
|
{
|
|
return $this->hasMany(StockEntry::class);
|
|
}
|
|
}
|