2025-12-18 14:27:10 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Loan;
|
|
|
|
|
|
2026-01-13 19:45:44 +09:00
|
|
|
use App\Http\Requests\Traits\HasPagination;
|
2025-12-18 14:27:10 +09:00
|
|
|
use App\Models\Tenants\Loan;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
|
|
class LoanIndexRequest extends FormRequest
|
|
|
|
|
{
|
2026-01-13 19:45:44 +09:00
|
|
|
use HasPagination;
|
|
|
|
|
|
2025-12-18 14:27:10 +09:00
|
|
|
/**
|
|
|
|
|
* 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 [
|
|
|
|
|
'user_id' => ['nullable', 'integer', 'exists:users,id'],
|
|
|
|
|
'status' => ['nullable', 'string', Rule::in(Loan::STATUSES)],
|
|
|
|
|
'start_date' => ['nullable', 'date', 'date_format:Y-m-d'],
|
|
|
|
|
'end_date' => ['nullable', 'date', 'date_format:Y-m-d', 'after_or_equal:start_date'],
|
|
|
|
|
'search' => ['nullable', 'string', 'max:100'],
|
|
|
|
|
'sort_by' => ['nullable', 'string', Rule::in(['loan_date', 'amount', 'status', 'created_at'])],
|
|
|
|
|
'sort_dir' => ['nullable', 'string', Rule::in(['asc', 'desc'])],
|
2026-01-13 19:45:44 +09:00
|
|
|
'per_page' => ['nullable', 'integer', 'min:1'],
|
2025-12-18 14:27:10 +09:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation attribute names.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, string>
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'user_id' => __('validation.attributes.user_id'),
|
|
|
|
|
'status' => __('validation.attributes.status'),
|
|
|
|
|
'start_date' => __('validation.attributes.start_date'),
|
|
|
|
|
'end_date' => __('validation.attributes.end_date'),
|
|
|
|
|
'search' => __('validation.attributes.search'),
|
|
|
|
|
'sort_by' => __('validation.attributes.sort_by'),
|
|
|
|
|
'sort_dir' => __('validation.attributes.sort_dir'),
|
|
|
|
|
'per_page' => __('validation.attributes.per_page'),
|
|
|
|
|
];
|
|
|
|
|
}
|
2026-01-16 21:59:06 +09:00
|
|
|
}
|