2022-03-09 17:28:23 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2022-06-08 15:27:21 +02:00
|
|
|
use Illuminate\Support\Collection;
|
2022-03-09 17:28:23 +01:00
|
|
|
|
|
|
|
|
class TraceaEgg extends Model
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The primary key for the model.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2022-06-08 17:09:44 +02:00
|
|
|
protected $primaryKey = null;
|
2022-03-09 17:28:23 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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',
|
2022-08-31 16:02:00 +02:00
|
|
|
'packing_date',
|
2022-03-09 17:28:23 +01:00
|
|
|
'product_code',
|
|
|
|
|
'product_label',
|
|
|
|
|
'external_lot',
|
|
|
|
|
'dcr',
|
|
|
|
|
'ean_13'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that should be cast.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $casts = [
|
2022-08-31 16:02:00 +02:00
|
|
|
'packing_date' => 'date',
|
2022-03-09 17:28:23 +01:00
|
|
|
'laying_date' => 'date',
|
|
|
|
|
'dcr' => 'date'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Accessor codes EDE attribute
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Collection
|
|
|
|
|
*/
|
|
|
|
|
public function getCodeEdesAttribute(): Collection
|
|
|
|
|
{
|
|
|
|
|
return self::select('ede_code')
|
2022-06-15 13:42:05 +02:00
|
|
|
->where('box_code', $this->box_code)
|
2022-03-09 17:28:23 +01:00
|
|
|
->distinct()->get()->pluck('ede_code');
|
|
|
|
|
}
|
|
|
|
|
}
|