refactor(pagination): size 초과 시 오류 대신 자동 조정으로 변경
- config/pagination.php 추가 (기본값 중앙 관리) - HasPagination Trait 추가 (prepareForValidation에서 자동 조정) - 22개 IndexRequest에 Trait 적용, max 규칙 제거 - 특수 케이스: Employee($maxSize=500), Audit($maxSize=200) size/per_page가 최대값 초과 시 422 오류 대신 최대값으로 자동 조정되어 리스트가 빈 화면으로 표시되는 문제 해결 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Http\Requests\V1\AiReport;
|
||||
|
||||
use App\Http\Requests\Traits\HasPagination;
|
||||
use App\Models\Tenants\AiReport;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class AiReportListRequest extends FormRequest
|
||||
{
|
||||
use HasPagination;
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
@@ -16,7 +19,7 @@ public function authorize(): bool
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1'],
|
||||
'report_type' => ['nullable', 'string', Rule::in(array_keys(AiReport::REPORT_TYPES))],
|
||||
'status' => ['nullable', 'string', Rule::in(array_keys(AiReport::STATUSES))],
|
||||
'start_date' => ['nullable', 'date'],
|
||||
@@ -35,4 +38,4 @@ public function messages(): array
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Http\Requests\V1\Company;
|
||||
|
||||
use App\Http\Requests\Traits\HasPagination;
|
||||
use App\Models\CompanyRequest;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CompanyRequestIndexRequest extends FormRequest
|
||||
{
|
||||
use HasPagination;
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
@@ -22,8 +25,8 @@ public function rules(): array
|
||||
'end_date' => 'nullable|date|after_or_equal:start_date',
|
||||
'sort_by' => ['nullable', Rule::in(['created_at', 'company_name', 'status', 'processed_at'])],
|
||||
'sort_dir' => ['nullable', Rule::in(['asc', 'desc'])],
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'per_page' => 'nullable|integer|min:1',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Http\Requests\V1\Payment;
|
||||
|
||||
use App\Http\Requests\Traits\HasPagination;
|
||||
use App\Models\Tenants\Payment;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PaymentIndexRequest extends FormRequest
|
||||
{
|
||||
use HasPagination;
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
@@ -23,7 +26,7 @@ public function rules(): array
|
||||
'search' => ['nullable', 'string', 'max:100'],
|
||||
'sort_by' => ['nullable', 'string', 'in:created_at,paid_at,amount'],
|
||||
'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Http\Requests\V1\Plan;
|
||||
|
||||
use App\Http\Requests\Traits\HasPagination;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PlanIndexRequest extends FormRequest
|
||||
{
|
||||
use HasPagination;
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
@@ -19,7 +22,7 @@ public function rules(): array
|
||||
'search' => ['nullable', 'string', 'max:100'],
|
||||
'sort_by' => ['nullable', 'string', 'in:price,name,created_at'],
|
||||
'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Http\Requests\V1\Subscription;
|
||||
|
||||
use App\Http\Requests\Traits\HasPagination;
|
||||
use App\Models\Tenants\Subscription;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class SubscriptionIndexRequest extends FormRequest
|
||||
{
|
||||
use HasPagination;
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
@@ -23,7 +26,7 @@ public function rules(): array
|
||||
'end_date' => ['nullable', 'date', 'after_or_equal:start_date'],
|
||||
'sort_by' => ['nullable', 'string', 'in:started_at,ended_at,created_at'],
|
||||
'sort_dir' => ['nullable', 'string', 'in:asc,desc'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
|
||||
'per_page' => ['nullable', 'integer', 'min:1'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user