67 lines
2.1 KiB
PHP
67 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Lib\CafelApi\Models;
|
|
|
|
use App\Enums\BreederCivilty;
|
|
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
|
|
|
/**
|
|
*
|
|
* @author Jérémy Munsch <jeremy.munsch@ldc.fr>
|
|
*/
|
|
abstract class CafelPoultryBreeder extends CafelClientModel
|
|
{
|
|
/**
|
|
* Unique columns key
|
|
*
|
|
* @var array
|
|
*/
|
|
public const UNIQUE_COLUMN_KEYS = [
|
|
'cafel_code'
|
|
];
|
|
|
|
/**
|
|
* Validation rules from cafel Api
|
|
*
|
|
* @var array
|
|
*/
|
|
protected static $validationRules = [
|
|
'cafel_code' => 'required|numeric|min:0',
|
|
// Valeurs possibles pour civility : 1 M, 2 MME, 3 EUX, 4 ELLES .
|
|
'civility' => ['required', [EnumIsValidRule::class, BreederCivilty::class]],
|
|
'lastname' => 'required|string|min:1|max:255',
|
|
'firstname' => 'required|string|min:1|max:255',
|
|
'birth_date' => 'required|date_format:Y-m-d',
|
|
'postcode' => 'required|numeric',
|
|
'city' => 'required|string|min:1|max:255',
|
|
'date_start_operation' => 'required|date_format:Y-m-d',
|
|
'inuavs' => 'required|array',
|
|
// Eg V072FXT (un seul par ligne).
|
|
'inuavs.*' => 'required|string|regex:/^[A-Z]\d{3}[A-Z]{3}$/',
|
|
'issue_1' => 'nullable|string',
|
|
'issue_2' => 'nullable|string',
|
|
'path_picture_1' => 'nullable|string|regex:/^https:\/\/base\.loue\.fr\/api\/ldc\/photoEleveur\?idPhoto=\d+$/',
|
|
'path_picture_2' => 'nullable|string|regex:/^https:\/\/base\.loue\.fr\/api\/ldc\/photoEleveur\?idPhoto=\d+$/',
|
|
];
|
|
|
|
/**
|
|
* Column translations
|
|
*
|
|
* @var array
|
|
*/
|
|
protected static $columnsTranslations = [
|
|
'Cafel_code' => 'cafel_code',
|
|
'Civility' => 'civility',
|
|
'Lastname' => 'lastname',
|
|
'Firstname' => 'firstname',
|
|
'Birthday' => 'birth_date',
|
|
'Postcode' => 'postcode',
|
|
'City' => 'city',
|
|
'Date_start_operation' => 'date_start_operation',
|
|
'Inuav_code' => 'inuavs',
|
|
'Issue_1' => 'issue_1',
|
|
'Issue_2' => 'issue_2',
|
|
'Picture_1_url' => 'path_picture_1',
|
|
'Picture_2_url' => 'path_picture_2',
|
|
];
|
|
}
|