2023-10-20 16:56:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Commitments;
|
|
|
|
|
|
|
|
|
|
use App\Traits\Requests\HasPicture;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
|
|
class StoreCommitmentRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
use HasPicture;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return auth('backend')->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function prepareForValidation()
|
|
|
|
|
{
|
|
|
|
|
$this->merge([
|
|
|
|
|
'published' => $this->published ? true : false
|
|
|
|
|
]);
|
|
|
|
|
$this->mergePicture('picture');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
$rules = [
|
2023-11-06 12:57:17 +01:00
|
|
|
'title' => 'required|string|min:3|max:255',
|
|
|
|
|
'picture_alt' => 'required|string|min:3|max:255',
|
2023-10-20 16:56:44 +02:00
|
|
|
'picture_title' => 'required|string|min:3|max:255',
|
2023-11-06 12:57:17 +01:00
|
|
|
'published' => 'required|boolean',
|
2023-10-20 16:56:44 +02:00
|
|
|
];
|
|
|
|
|
return \array_merge(
|
|
|
|
|
$rules,
|
|
|
|
|
$this->pictureRules('picture', 185, 185, 185, 185, false),
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-11-06 12:57:17 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get custom attributes for validator errors.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'title' => trans('validation.attributes.title'),
|
|
|
|
|
'picture_alt' => trans('validation.custom.picture_alt', ['field' => __('validation.custom.picture')]),
|
|
|
|
|
'picture_title' => trans('validation.custom.picture_title', ['field' => __('validation.custom.picture')]),
|
|
|
|
|
'published' => trans('validation.attributes.published'),
|
|
|
|
|
];
|
|
|
|
|
}
|
2023-10-20 16:56:44 +02:00
|
|
|
}
|