'date' ]; /** * Map attribute names to enum classes. * * @var array */ protected $enumCasts = [ 'food_type' => FoodType::class ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'batch_code', 'food_type', 'delivery_date' ]; // * METHODS /** * Get Food using cafel lot code * * @param \App\Enums\FoodType $food_type * @param integer $codeLotCafel * @return self|null */ public static function whereCodeLotCafel(FoodType $food_type, int $codeLotCafel): ?self { return Cache::remember("foodCafel$codeLotCafel", 5, function () use ($food_type, $codeLotCafel) { return self::where( 'batch_code', 'LIKE', '%' . \filter_var($codeLotCafel, \FILTER_SANITIZE_STRING) . '/%' )->whereFoodType($food_type)->first(); }); } }