45 lines
1,008 B
PHP
45 lines
1,008 B
PHP
<?php
|
|
|
|
namespace App\Lib\CafelApi\Models;
|
|
|
|
use App\Enums\FoodType;
|
|
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
|
|
|
/**
|
|
* @author Jérémy Munsch <jeremy.munsch@ldc.fr>
|
|
*/
|
|
abstract class CafelFood extends CafelClientModel
|
|
{
|
|
/**
|
|
* Unique columns key
|
|
*
|
|
* @var array
|
|
*/
|
|
public const UNIQUE_COLUMN_KEYS = [
|
|
'batch_code', 'delivery_date'
|
|
];
|
|
|
|
/**
|
|
* Validation rules from cafel Api
|
|
*
|
|
* @var array
|
|
*/
|
|
protected static $validationRules = [
|
|
// 1 Pondeuse ou 2 Poulet .
|
|
'food_type' => ['required', [EnumIsValidRule::class, FoodType::class]],
|
|
// Eg 19377/0 .
|
|
'batch_code' => 'required|max:10|regex:/^[0-9A-Z]*\/\d$/',
|
|
'delivery_date' => 'required|date_format:Y-m-d'
|
|
];
|
|
|
|
/**
|
|
* Column translations
|
|
*
|
|
* @var array
|
|
*/
|
|
protected static $columnsTranslations = [
|
|
'Food_type' => 'food_type',
|
|
'Batch_code' => 'batch_code',
|
|
'Delivery_date' => 'delivery_date'
|
|
];
|
|
}
|