39 lines
849 B
PHP
39 lines
849 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Product extends Model
|
|
{
|
|
protected $fillable = ['title', 'description', 'images', 'package_content', 'recipes_id'];
|
|
|
|
protected $casts = [
|
|
'images' => 'array',
|
|
];
|
|
|
|
|
|
public function recipe()
|
|
{
|
|
return $this->belongsTo(Recipe::class, 'recipes_id');
|
|
}
|
|
|
|
public function sizes()
|
|
{
|
|
return $this->belongsToMany(Packing::class, 'products_sizes')
|
|
->withPivot('price')
|
|
->withPivot('description')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function inventories()
|
|
{
|
|
return $this->hasMany(ProductInventory::class);
|
|
}
|
|
|
|
public function batches()
|
|
{
|
|
return $this->hasMany(Batch::class);
|
|
}
|
|
} |