ldc-flucollector/app/Models/XmlInco.php

80 lines
1.4 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
2022-04-06 10:36:10 +02:00
/**
* XmlInco
*
* pictures attribute is organized as following
* [
* 'checksum' => 'storageFilePath'
* ]
*
* ! checksum includes fullfilepath + data
*/
class XmlInco extends Model
{
use HasFactory;
2022-04-06 10:36:10 +02:00
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'id',
'no_art',
'prod_saison',
'allegations',
'conseil_prepa',
'astuces',
'descriptif',
'arg_vente',
'nb_portion',
'typ_portion',
'pds_moy_theo',
'lib_conso',
'lst_ing',
'lib_allergene',
'nutritional_values',
2022-04-06 10:36:10 +02:00
'pictures',
];
/**
2022-04-06 10:36:10 +02:00
* The attributes that should be cast.
*
* @var array
*/
2022-04-06 10:36:10 +02:00
protected $casts = [
'pictures' => 'array',
'nutritional_values' => 'array',
];
2022-04-06 10:36:10 +02:00
// * GETTERS
/**
2022-04-06 10:36:10 +02:00
* Get niceString attribute
*
* @return string
*/
2022-04-06 10:36:10 +02:00
public function getNiceStringAttribute(): string
{
2022-04-06 10:36:10 +02:00
return sprintf('%s - %s', $this->id, $this->descriptif);
}
2022-04-06 10:36:10 +02:00
// * RELATIONS
/**
2022-04-06 10:36:10 +02:00
* ArcadiaBrand belongsTo relation
*
2022-04-06 10:36:10 +02:00
* @return \Illuminate\Database\Eloquent\Relations\belongsTo
*/
2022-04-06 10:36:10 +02:00
public function arcadiaBrand()
{
2022-04-06 10:36:10 +02:00
return $this->belongsTo(ArcadiaBrand::class);
}
}