v7.0.0-beta.1 release
This commit is contained in:
commit
6595fd0eb5
3967 files changed
+1875383
No files matched your search
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Role;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RoleListRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => 'integer|min:1|max:100',
|
||||
'search' => 'nullable|string|max:255',
|
||||
'is_active' => 'nullable|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'page.integer' => __('validation.integer', ['attribute' => 'page']),
|
||||
'page.min' => __('validation.min.numeric', ['attribute' => 'page', 'min' => 1]),
|
||||
'per_page.integer' => __('validation.integer', ['attribute' => 'per_page']),
|
||||
'per_page.min' => __('validation.min.numeric', ['attribute' => 'per_page', 'min' => 1]),
|
||||
'per_page.max' => __('validation.max.numeric', ['attribute' => 'per_page', 'max' => 100]),
|
||||
'search.max' => __('validation.max.string', ['attribute' => 'search', 'max' => 255]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* 쿼리 파라미터 문자열 "true"/"false"를 boolean으로 변환합니다.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if ($this->has('is_active') && is_string($this->is_active)) {
|
||||
$this->merge([
|
||||
'is_active' => filter_var($this->is_active, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user