ldc-legaulois/app/Http/Requests/Bo/Videos/StoreVideoRequest.php
2026-09-25 16:25:31 +02:00

59 lines
1.6 KiB
PHP

<?php
namespace App\Http\Requests\Bo\Videos;
use App\Models\Video;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class StoreVideoRequest extends FormRequest
{
use HasPicture;
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return Gate::check('create', Video::class);
}
/**
* Prepare the data for validation.
*/
protected function prepareForValidation(): void
{
$this->merge([
'published' => $this->boolean('published'),
'is_on_homepage' => $this->boolean('is_on_homepage'),
]);
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'title' => 'required|string|between:3,255',
'video_id' => 'required|string|between:3,255',
'product_id' => 'sometimes|nullable|integer|exists:products,id',
'is_on_homepage' => 'required|boolean',
'published' => 'required|boolean',
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'title' => trans('validation.attributes.title'),
'video_id' => trans('validation.custom.video_id'),
'is_on_homepage' => trans('validation.custom.on_homepage'),
'published' => trans('validation.custom.published'),
];
}
}