44 lines
914 B
PHP
44 lines
914 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Product extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'sku',
|
|
'product_category_id',
|
|
'branch_id',
|
|
'cost_price',
|
|
'selling_price',
|
|
'current_stock',
|
|
'reorder_level',
|
|
'status',
|
|
'image'
|
|
];
|
|
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProductCategory::class, 'product_category_id');
|
|
}
|
|
|
|
public function branch(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Branch::class);
|
|
}
|
|
|
|
public function adjustments(): HasMany
|
|
{
|
|
return $this->hasMany(StockAdjustment::class);
|
|
}
|
|
|
|
public function saleItems(): HasMany
|
|
{
|
|
return $this->hasMany(ProductSaleItem::class);
|
|
}
|
|
}
|