feat(tickets): add tenant-aware server-side sorting

This commit is contained in:
2026-08-31 13:45:57 -03:00
parent 6a00d8d09c
commit fa1e11a69f
5 changed files with 251 additions and 22 deletions

View File

@@ -3,6 +3,7 @@
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;
@@ -16,6 +17,11 @@ class AdminAppTicketIndexRequest extends FormRequest
/** @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'],
@@ -33,6 +39,8 @@ class AdminAppTicketIndexRequest extends FormRequest
],
'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'])],
];
}
}