Initial commit
This commit is contained in:
34
app/Models/Product.php
Normal file
34
app/Models/Product.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'products';
|
||||
|
||||
protected $fillable = [
|
||||
'sort_order',
|
||||
'category',
|
||||
'products',
|
||||
'description'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'products' => 'array',
|
||||
];
|
||||
|
||||
public function ingredients()
|
||||
{
|
||||
return Ingredient::whereIn('id', collect($this->products ?? [])
|
||||
->pluck('ingredients')
|
||||
->flatten()
|
||||
->unique()
|
||||
->toArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user