41 lines
766 B
PHP
41 lines
766 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use App\Models\ProductCategory;
|
||
|
|
|
||
|
|
class Product extends Model
|
||
|
|
{
|
||
|
|
/** @use HasFactory<\Database\Factories\ProductFactory> */
|
||
|
|
use HasFactory;
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'title',
|
||
|
|
'description',
|
||
|
|
'notes',
|
||
|
|
'vendor_url',
|
||
|
|
'category_id',
|
||
|
|
'price',
|
||
|
|
'margin',
|
||
|
|
'unit_id',
|
||
|
|
'image',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'price' => 'decimal:2',
|
||
|
|
'margin' => 'decimal:2'
|
||
|
|
];
|
||
|
|
|
||
|
|
public function category()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(ProductCategory::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function unit()
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Unit::class);
|
||
|
|
}
|
||
|
|
}
|