49 lines
1,017 B
PHP
49 lines
1,017 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\CodesEan;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreCodeEanRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return auth()->check();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
'code' => [
|
|
'required',
|
|
'numeric',
|
|
'unique:code_eans,code',
|
|
'regex:/^[0-9]{7}$|^[0-9]{8}$|^[0-9]{13}$/',
|
|
],
|
|
'product' => 'required|string|min:3|max:255',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'code' => trans('Code EAN'),
|
|
'product' => trans('Produit'),
|
|
];
|
|
}
|
|
}
|