vat_wms/app/Models/PhysicalItem.php

57 lines
1.3 KiB
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 PhysicalItem extends Model
{
use HasFactory;
/**
* The database connection that should be used by the model.
*
* @var string
*/
protected $connection = 'vat_warehouse';
protected $table = 'physical_item';
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'physical_item_type_id',
'manufacturer_id',
'in_stock',
'blocked',
'selling_price',
'description',
'created_by',
'updated_by'
];
/**
* Get the stock entries for this physical item.
*/
public function stockEntries(): HasMany
{
return $this->hasMany(StockEntry::class, 'physical_item_id');
}
public function manufacturer()
{
return $this->hasOne(Manufacturer::class, 'id', 'manufacturer_id');
}
public function type(): BelongsTo
{
return $this->belongsTo(PhysicalItemType::class, 'physical_item_type_id');
}
}