ldc-com-app-bo/app/Http/Requests/Bo/Documents/StoreDocumentRequest.php
Vincent BRIDIER 777d3e0e86 Multiple fix
2023-07-13 08:34:54 +00:00

73 lines
1.9 KiB
PHP

<?php
namespace App\Http\Requests\Bo\Documents;
use App\Enums\Documents\LangEnum;
use Illuminate\Foundation\Http\FormRequest;
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
class StoreDocumentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return auth('backend')->check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
'status' => $this->status ? true : false
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'directory_id' => 'sometimes|nullable|integer',
'document_id' => 'sometimes|nullable|integer',
'uuid' => 'required|min:3|max:255',
'title' => 'required|min:3|max:255',
'type' => 'required|min:3|max:255',
'path' => 'required|min:3|max:255',
'lang' => [
'required',
new EnumIsValidRule(LangEnum::class)
],
'status' => 'required|boolean'
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes()
{
return [
'directory_id' => \trans('dossier à associer'),
'document_id' => \trans('document (FR) à associer'),
'title' => \trans('titre'),
'uuid' => \trans('document'),
'type' => \trans('type du document'),
'path' => \trans('chemin du document'),
'lang' => \trans('langue du document'),
'status' => \trans('état de publication du document'),
];
}
}