fix : 컨트롤러 검증 → FormRequest 분리

This commit is contained in:
2025-09-08 02:28:14 +09:00
parent d9563c96cb
commit 4bf02b7424
9 changed files with 204 additions and 26 deletions

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests\Common;
use Illuminate\Foundation\Http\FormRequest;
class PaginateRequest extends FormRequest
{
public function authorize(): bool { return true; }
public function rules(): array
{
return [
'page' => 'nullable|integer|min:1',
'size' => 'nullable|integer|min:1|max:100',
'q' => 'nullable|string|max:100',
'sort' => 'nullable|string|in:id,code,name,created_at',
'order' => 'nullable|string|in:asc,desc',
];
}
public function validatedOrDefaults(): array
{
$v = $this->validated();
$v['page'] = $v['page'] ?? 1;
$v['size'] = $v['size'] ?? 20;
$v['order'] = $v['order'] ?? 'desc';
return $v;
}
}