ldc-boutique-cnc-sable/app/Models/XmlInco.php

106 lines
2.3 KiB
PHP
Raw Normal View History

2021-04-21 11:06:40 +02:00
<?php
2026-06-14 21:32:07 +02:00
declare(strict_types=1);
2021-04-21 11:06:40 +02:00
namespace App\Models;
2026-06-14 21:32:07 +02:00
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Casts\Attribute;
2021-04-21 11:06:40 +02:00
use Illuminate\Database\Eloquent\Model;
2021-04-27 17:34:55 +02:00
use Illuminate\Support\Facades\Storage;
2021-04-21 11:06:40 +02:00
2026-06-14 21:32:07 +02:00
/**
* @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',
])]
2021-04-21 11:06:40 +02:00
class XmlInco extends Model
{
2021-04-27 17:34:55 +02:00
/**
* The Laravel disk name
*
* @var string
*/
protected $disk = 'inco';
2022-09-08 13:02:16 +02:00
/**
* Storage path
*
* @var string
*/
2021-04-27 17:34:55 +02:00
protected $imagesPath = 'images';
/**
* The files to ignore
*
2026-06-14 21:32:07 +02:00
* @var array<string>
2021-04-27 17:34:55 +02:00
*/
protected $ignoreFiles = [
2026-06-14 21:32:07 +02:00
'.gitignore',
'.gitkeep',
2021-04-27 17:34:55 +02:00
];
/**
* Get the concerned disk
*/
protected function getDisk(): Filesystem
{
return Storage::disk($this->disk);
}
2026-06-14 21:32:07 +02:00
/** @return \Illuminate\Database\Eloquent\Casts\Attribute<string,never> */
protected function niceString(): Attribute
2021-04-21 11:06:40 +02:00
{
2026-06-14 21:32:07 +02:00
return Attribute::make(get: fn (): string => sprintf('%s - %s', $this->id, $this->descriptif));
2021-04-21 11:06:40 +02:00
}
2021-04-26 12:16:17 +02:00
2026-06-14 21:32:07 +02:00
#[\Override]
protected function casts(): array
2021-04-26 12:16:17 +02:00
{
2026-06-14 21:32:07 +02:00
return [
'prod_saison' => 'bool',
'picture' => 'array',
'nutritional_values' => 'array',
2021-04-26 12:16:17 +02:00
2026-06-14 21:32:07 +02:00
];
2021-04-26 12:16:17 +02:00
}
2021-04-21 11:06:40 +02:00
}