46 lines
902 B
PHP
46 lines
902 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Bo\Codes;
|
|
|
|
use App\Models\Code;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class CodeSearchRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return Gate::check('search', Code::class);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string,string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'code' => 'required|string|min:1|max:25',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array<string,string>
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'code' => trans('code'),
|
|
];
|
|
}
|
|
}
|