ldc-boutique-cnc-sable/app/Models/XmlInco.php
2026-10-27 09:58:12 +01:00

105 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
/**
* @property int $id
* @property string|null $nom
* @property bool $prod_saison
* @property string|null $allegations
* @property string|null $descriptif
* @property array<array-key, mixed> $picture
* @property string|null $astuces
* @property string|null $lib_conso
* @property string|null $nb_portion
* @property string|null $typ_portion
* @property string|null $pds_moy_theo
* @property string|null $conseil_prepa
* @property string|null $arg_vente
* @property string|null $lst_ing
* @property string|null $lib_allergene
* @property array<array-key, mixed> $nutritional_values
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read string $nice_string
*
* @mixin \Eloquent
*/
#[Fillable([
'id',
'no_art',
'nom',
'prod_saison',
'allegations',
'conseil_prepa',
'astuces',
'descriptif',
'arg_vente',
'nb_portion',
'typ_portion',
'pds_moy_theo',
'lib_conso',
'lst_ing',
'lib_allergene',
'nutritional_values',
'picture',
])]
class XmlInco extends Model
{
/**
* The Laravel disk name
*
* @var string
*/
protected $disk = 'inco';
/**
* Storage path
*
* @var string
*/
protected $imagesPath = 'images';
/**
* The files to ignore
*
* @var array<string>
*/
protected $ignoreFiles = [
'.gitignore',
'.gitkeep',
];
/**
* Get the concerned disk
*/
protected function getDisk(): Filesystem
{
return Storage::disk($this->disk);
}
/** @return \Illuminate\Database\Eloquent\Casts\Attribute<string,never> */
protected function niceString(): Attribute
{
return Attribute::make(get: fn (): string => sprintf('%s - %s', $this->id, $this->descriptif));
}
#[\Override]
protected function casts(): array
{
return [
'prod_saison' => 'bool',
'picture' => 'array',
'nutritional_values' => 'array',
];
}
}