ldc-bogt/app/Models/TraceaEgg.php
Jérémy Munsch 7cb304e967
Full traça poulets
Cafel APi Eat
Xml flux new
Full Models Rework
Refactorize
2022-06-08 11:44:01 +02:00

68 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
class TraceaEgg extends Model
{
/**
* The primary key for the model.
*
* @var string
*/
protected $primaryKey = 'box_code';
/**
* Indicates if the IDs are auto-incrementing.
*
* @var boolean
*/
public $incrementing = false;
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'box_code',
'ede_code',
'laying_date',
'product_code',
'product_label',
'external_lot',
'dcr',
'ean_13'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'laying_date' => 'date',
'dcr' => 'date'
];
/**
* Accessor codes EDE attribute
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getCodeEdesAttribute(): Collection
{
return self::select('ede_code')
->where('box_code', $this->code_boite)
->distinct()->get()->pluck('ede_code');
}
}