70 lines
1.3 KiB
PHP
70 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class TraceaEgg extends Model
|
|
{
|
|
/**
|
|
* The primary key for the model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $primaryKey = null;
|
|
|
|
/**
|
|
* 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',
|
|
'packing_date',
|
|
'product_code',
|
|
'product_label',
|
|
'external_lot',
|
|
'dcr',
|
|
'ean_13'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'packing_date' => 'date',
|
|
'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->box_code)
|
|
->distinct()->get()->pluck('ede_code');
|
|
}
|
|
}
|