Attempt to fix N+1 issues
This commit is contained in:
@@ -55,6 +55,9 @@ final class TicketShow extends Component
|
||||
|
||||
public function mount(Ticket $ticket): void
|
||||
{
|
||||
Auth::user()?->loadMissing('company');
|
||||
$ticket->loadMissing(['owner.company', 'agent.company']);
|
||||
|
||||
$this->authorize('view', $ticket);
|
||||
$this->ticket = $this->freshTicket($ticket);
|
||||
$this->status_id = $this->ticket->status_id;
|
||||
@@ -295,13 +298,13 @@ final class TicketShow extends Component
|
||||
'ratings',
|
||||
'tags',
|
||||
'checklistItems',
|
||||
'attachments.user',
|
||||
'attachments.user.company',
|
||||
'gitCommits.repository',
|
||||
]) ?? $ticket;
|
||||
|
||||
$comments = \Modules\Helpdesk\Models\Comment::query()
|
||||
->where('ticket_id', $ticket->id)
|
||||
->with(['user', 'attachments.user'])
|
||||
->with(['user.company', 'attachments.user.company'])
|
||||
->oldest()
|
||||
->get();
|
||||
|
||||
@@ -326,7 +329,7 @@ final class TicketShow extends Component
|
||||
$columns[] = 'company_id';
|
||||
}
|
||||
|
||||
$query = User::query()->select($columns)->orderBy('name');
|
||||
$query = User::query()->select($columns)->with('company')->orderBy('name');
|
||||
|
||||
if ($this->ticket->company_id !== null && Schema::hasColumn('users', 'company_id')) {
|
||||
$tenantUsers = (clone $query)
|
||||
|
||||
Reference in New Issue
Block a user