ldc-agis/app/Http/Requests/Bo/Joinuspage/UpdateJoinuspageRequest.php

53 lines
1.3 KiB
PHP
Raw Normal View History

2023-12-19 15:09:12 +00:00
<?php
namespace App\Http\Requests\Bo\Joinuspage;
use App\Rules\IsValidVimeoId;
use App\Rules\IsValidYoutubeId;
2023-12-19 15:09:12 +00:00
use Illuminate\Foundation\Http\FormRequest;
class UpdateJoinuspageRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return auth('backend')->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'video_id' => [
'required', 'string',
function (string $attribute, mixed $value, \Closure $fail) {
if (!IsValidYoutubeId::validates($value) and !IsValidVimeoId::validates($value)) {
(new IsValidYoutubeId())->validate($attribute, $value, $fail);
(new IsValidVimeoId())->validate($attribute, $value, $fail);
}
}
],
2023-12-19 15:09:12 +00:00
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'video_id' => trans('validation.custom.video_id'),
];
}
}