118 lines
3.2 KiB
PHP
118 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Casts\NutritionalValuesCast;
|
|
use Domain\Enums\Nutriscore;
|
|
use Domain\Models\ValueObjects\IncoId;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $product_id
|
|
* @property int $no_art
|
|
* @property string|null $ingredients
|
|
* @property string|null $preparation
|
|
* @property string|null $servings
|
|
* @property string|null $allergens
|
|
* @property string|null $selling_argument
|
|
* @property float|null $nv_ref_weight_g
|
|
* @property float|null $nv_kj
|
|
* @property float|null $nv_kcal
|
|
* @property float|null $nv_fat_g
|
|
* @property float|null $nv_sat_fat_g
|
|
* @property float|null $nv_carb_g
|
|
* @property float|null $nv_sugar_g
|
|
* @property float|null $nv_fiber_g
|
|
* @property float|null $nv_protein_g
|
|
* @property float|null $nv_salt_g
|
|
* @property float|null $nv_serving_size_g
|
|
* @property float|null $nv_serving_kj
|
|
* @property float|null $nv_serving_kcal
|
|
* @property float|null $nv_serving_fat_g
|
|
* @property float|null $nv_serving_sat_fat_g
|
|
* @property float|null $nv_serving_carb_g
|
|
* @property float|null $nv_serving_sugar_g
|
|
* @property float|null $nv_serving_fiber_g
|
|
* @property float|null $nv_serving_protein_g
|
|
* @property float|null $nv_serving_salt_g
|
|
* @property float|null $nv_daily_energy
|
|
* @property float|null $nv_daily_fat
|
|
* @property float|null $nv_daily_sat_fat
|
|
* @property float|null $nv_daily_carb
|
|
* @property float|null $nv_daily_sugar
|
|
* @property float|null $nv_daily_fiber
|
|
* @property float|null $nv_daily_protein
|
|
* @property float|null $nv_daily_salt
|
|
* @property Nutriscore|null $nutriscore
|
|
* @property string|null $nutriscore_args
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @property \Domain\Models\ValueObjects\NutritionalValues $nutrition
|
|
* @property-read \App\Models\Product|null $product
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
#[Fillable([
|
|
'ingredients',
|
|
'preparation',
|
|
'servings',
|
|
'allergens',
|
|
'selling_argument',
|
|
'nutriscore',
|
|
'nutriscore_args',
|
|
'nv_ref_weight_g',
|
|
'nv_kj',
|
|
'nv_kcal',
|
|
'nv_fat_g',
|
|
'nv_sat_fat_g',
|
|
'nv_carb_g',
|
|
'nv_sugar_g',
|
|
'nv_fiber_g',
|
|
'nv_protein_g',
|
|
'nv_salt_g',
|
|
'nv_serving_size_g',
|
|
'nv_serving_kj',
|
|
'nv_serving_kcal',
|
|
'nv_serving_fat_g',
|
|
'nv_serving_sat_fat_g',
|
|
'nv_serving_carb_g',
|
|
'nv_serving_sugar_g',
|
|
'nv_serving_fiber_g',
|
|
'nv_serving_protein_g',
|
|
'nv_serving_salt_g',
|
|
'nv_daily_energy',
|
|
'nv_daily_fat',
|
|
'nv_daily_sat_fat',
|
|
'nv_daily_carb',
|
|
'nv_daily_sugar',
|
|
'nv_daily_fiber',
|
|
'nv_daily_protein',
|
|
'nv_daily_salt',
|
|
])]
|
|
class ProductInco extends Model
|
|
{
|
|
public function getId(): IncoId
|
|
{
|
|
return new IncoId($this->id);
|
|
}
|
|
|
|
/** @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Product,$this> */
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
#[\Override]
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'nutriscore' => Nutriscore::class,
|
|
'nutrition' => NutritionalValuesCast::class,
|
|
];
|
|
}
|
|
}
|