60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Product extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'description',
|
|
'price',
|
|
'image',
|
|
'ingredients',
|
|
'allergens',
|
|
'nutritional_values',
|
|
'energy_kj',
|
|
'energy_kcal',
|
|
'fat',
|
|
'saturated_fat',
|
|
'carbohydrates',
|
|
'sugars',
|
|
'protein',
|
|
'salt',
|
|
'net_weight',
|
|
'best_before',
|
|
'storage_conditions',
|
|
'origin',
|
|
'manufacturer',
|
|
'usage_instructions',
|
|
'tenant_id'
|
|
];
|
|
|
|
protected $casts = [
|
|
'price' => 'decimal:2',
|
|
'fat' => 'decimal:2',
|
|
'saturated_fat' => 'decimal:2',
|
|
'carbohydrates' => 'decimal:2',
|
|
'sugars' => 'decimal:2',
|
|
'protein' => 'decimal:2',
|
|
'salt' => 'decimal:2',
|
|
];
|
|
|
|
public function slots(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Slot::class, 'slot_product')
|
|
->withPivot('quantity', 'current_price')
|
|
->withTimestamps();
|
|
}
|
|
|
|
/**
|
|
* Beziehung zum Mandanten
|
|
*/
|
|
public function tenant()
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
}
|