It fixes the remaining stale test and keeps the actual N+1 strategy:
* Main ticket index renders scalar agent_name. * Ticket index still eager-loads user, owner, agent. * Ticket show comments no longer eager-load fake owner / agent relations. * Updated the conflicting regression tests.
This commit is contained in:
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\User;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
@@ -124,6 +125,13 @@ final class TicketIndex extends Component
|
||||
$search = trim($this->search);
|
||||
|
||||
return Ticket::query()
|
||||
->select('helpdesk_tickets.*')
|
||||
->addSelect([
|
||||
'agent_name' => User::query()
|
||||
->select('name')
|
||||
->whereColumn('users.id', 'helpdesk_tickets.agent_id')
|
||||
->limit(1),
|
||||
])
|
||||
->with(['user:id,name,email', 'owner:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team'])
|
||||
->withCount('attachments')
|
||||
->visibleTo($user)
|
||||
|
||||
Reference in New Issue
Block a user