<?php

namespace App\Http\Requests\Approval;

use App\Http\Requests\Traits\HasPagination;
use App\Models\Tenants\Approval;
use Illuminate\Foundation\Http\FormRequest;

class IndexRequest extends FormRequest
{
    use HasPagination;

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        $statuses = implode(',', Approval::STATUSES);

        return [
            'status' => "nullable|string|in:{$statuses}",
            'search' => 'nullable|string|max:100',
            'sort_by' => 'nullable|string|in:created_at,drafted_at,completed_at,title,status',
            'sort_dir' => 'nullable|string|in:asc,desc',
            'per_page' => 'nullable|integer|min:1',
            'page' => 'nullable|integer|min:1',
        ];
    }
}
