ldc-volena/app/Http/Requests/Bo/Logos/StoreLogoRequest.php

72 lines
1.9 KiB
PHP
Raw Permalink Normal View History

2023-11-24 14:54:02 +01:00
<?php
namespace App\Http\Requests\Bo\Logos;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
class StoreLogoRequest 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
*/
2024-03-20 17:39:24 +01:00
protected function prepareForValidation(): void
2023-11-24 14:54:02 +01:00
{
$this->mergePicture('picture');
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
2023-11-24 14:54:02 +01:00
*/
public function rules(): array
{
$rules = [
'label' => 'required|string|between:3,255',
'picture_alt' => 'required|string|between:3,255',
'picture_title' => 'required|string|between:3,255',
2023-11-24 14:54:02 +01:00
];
return \array_merge(
$rules,
2024-03-20 17:39:24 +01:00
$this->pictureRules('picture', 450, 450, 450, 450, false),
2023-11-24 14:54:02 +01:00
);
}
/**
* Get custom attributes for validator errors.
*
* @return array<string, string>
2023-11-24 14:54:02 +01:00
*/
public function attributes(): array
{
return [
2024-03-20 17:39:24 +01:00
'picture_alt' => trans(':field :inter:model', [
'field' => trans('validation.custom.alt_attribute'),
'inter' => trans('validation.custom.of_the.vowel'),
'model' => trans('validation.custom.picture'),
2023-11-24 14:54:02 +01:00
]),
2024-03-20 17:39:24 +01:00
'picture_title' => trans(':field :inter:model', [
'field' => trans('validation.custom.title_attribute'),
'inter' => trans('validation.custom.of_the.vowel'),
'model' => trans('validation.custom.picture'),
2023-11-24 14:54:02 +01:00
]),
];
}
}