55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Sites;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class StoreSiteRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::allows('isAdmin');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => 'required|string|min:3|max:255',
|
|
'users' => 'nullable|array',
|
|
'users.*.id' => 'required|exists:users,id',
|
|
'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id',
|
|
'project_manager_id' => 'nullable|exists:users,id',
|
|
'url_re7' => 'nullable|url',
|
|
'url_prod' => 'nullable|url'
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'name' => trans('Nom du site'),
|
|
'users' => trans('Utilisateurs associés au site'),
|
|
'users.*.id' => trans('Élément parmis les Utilisateurs associés au site'),
|
|
'gitlab_project_id' => trans('ID du dépôt Gitlab'),
|
|
'project_manager_id' => trans('Chef de projet'),
|
|
'url_re7' => trans('Url de RECETTE'),
|
|
'url_prod' => trans('Url de prod')
|
|
];
|
|
}
|
|
}
|