48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Ticket\Requests;
|
|
|
|
use App\Domains\Ticket\Models\Ticket;
|
|
use App\Domains\Ticket\Services\AdminAppTicketColumnService;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class AdminAppTicketIndexRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/** @return array<string, list<string>> */
|
|
public function rules(): array
|
|
{
|
|
$tenant = $this->user()?->tenant()->first();
|
|
$sortableKeys = $tenant === null
|
|
? []
|
|
: app(AdminAppTicketColumnService::class)->sortableKeys($tenant);
|
|
|
|
return [
|
|
'q' => ['sometimes', 'nullable', 'string', 'max:255'],
|
|
'category' => ['sometimes', 'nullable', 'string', 'max:255'],
|
|
'product' => ['sometimes', 'nullable', 'string', 'max:255'],
|
|
'type' => ['sometimes', 'nullable', 'string', 'max:255'],
|
|
'date' => ['sometimes', 'nullable', 'date_format:Y-m-d'],
|
|
'size' => ['sometimes', 'nullable', 'string', 'max:255'],
|
|
'status' => [
|
|
'sometimes',
|
|
'nullable',
|
|
Rule::in([
|
|
Ticket::STATUS_ACTIVE,
|
|
Ticket::STATUS_USED,
|
|
Ticket::STATUS_EXPIRED,
|
|
]),
|
|
],
|
|
'page' => ['sometimes', 'integer', 'min:1'],
|
|
'per_page' => ['sometimes', 'integer', 'min:1', 'max:100'],
|
|
'sort_by' => ['sometimes', 'nullable', 'string', Rule::in($sortableKeys)],
|
|
'sort_direction' => ['sometimes', 'nullable', 'string', Rule::in(['asc', 'desc'])],
|
|
];
|
|
}
|
|
}
|