ldc-bogt/app/Lib/CafelApi/Models/CafelFood.php
2022-10-27 12:24:43 +02:00

49 lines
1 KiB
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|[A-Z])$/',
],
'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'
];
}