41 lines
1017 B
PHP
41 lines
1017 B
PHP
<?php
|
|
|
|
namespace Modules\Banner\app\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Contracts\Validation\Validator;
|
|
|
|
class CreateBannerRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'title' => 'required',
|
|
'link' => 'sometimes',
|
|
'ordering' => 'required|integer|unique:banners,ordering',
|
|
'caption' => 'sometimes',
|
|
'status' => 'required',
|
|
'image' => 'sometimes|nullable',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
// return auth()->user()->can('users.create');
|
|
}
|
|
|
|
protected function failedValidation(Validator $validator)
|
|
{
|
|
$message = $validator->errors()->first();
|
|
toastr()->error($message);
|
|
parent::failedValidation($validator);
|
|
}
|
|
}
|