settings updates, fixed

This commit is contained in:
Mark Gregory
2026-08-25 22:30:59 +01:00
parent 1cad54ce42
commit d359ac29b6
13 changed files with 61 additions and 815 deletions
+3 -3
View File
@@ -73,7 +73,7 @@ final class KanbanBoard extends Component
'last_activity_at' => now(),
])->save();
$freshTicket = $ticket->fresh(['user:id,name,email', 'owner:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team', 'product', 'tags', 'checklistItems', 'board']) ?? $ticket;
$freshTicket = $ticket->fresh(['user:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team', 'product', 'tags', 'checklistItems', 'board']) ?? $ticket;
$workflow->dispatch(
$freshTicket,
@@ -121,7 +121,7 @@ final class KanbanBoard extends Component
$this->board_id = $board->id;
$fresh = $ticket->fresh(['user:id,name,email', 'owner:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team', 'board']) ?? $ticket;
$fresh = $ticket->fresh(['user:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team', 'board']) ?? $ticket;
$workflow->dispatch($fresh, 'ticket.updated', Auth::user());
$message = 'Ticket '.$fresh->reference.' moved from '.$oldBoardName.' to '.$board->name.'.';
@@ -206,7 +206,7 @@ final class KanbanBoard extends Component
}
return Ticket::query()
->with(['user:id,name,email', 'owner:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team', 'product', 'tags', 'checklistItems', 'board'])
->with(['user:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team', 'product', 'tags', 'checklistItems', 'board'])
->visibleTo(Auth::user())
->where('board_id', $board->id)
->latest('last_activity_at')
+14 -7
View File
@@ -27,7 +27,7 @@ final class Ticket extends Model
protected $table = 'helpdesk_tickets';
protected $with = ['user', 'owner', 'agent'];
protected $with = ['user'];
/** @var list<string> */
protected $fillable = [
@@ -62,17 +62,24 @@ final class Ticket extends Model
return $this->belongsTo(User::class, 'user_id');
}
/**
* Compatibility alias for the requester.
*
* This is deliberately an accessor, not another BelongsTo relation.
* `owner()` and `user()` previously pointed to the same users.user_id
* relation and caused duplicate User relationship queries.
*/
public function getOwnerAttribute(): ?User
{
return $this->user;
}
public function tickets(): Ticket|HasMany
{
return $this->hasMany(Ticket::class, 'ticket_id');
}
/** @return BelongsTo<User, Ticket> */
public function owner(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
/** @return BelongsTo<User, Ticket> */
public function agent(): BelongsTo
{
@@ -69,7 +69,7 @@ final class WorkflowNotificationService
*/
private function hydrateTicketUsers(Ticket $ticket): void
{
if ($ticket->relationLoaded('owner') && $ticket->relationLoaded('agent')) {
if ($ticket->relationLoaded('user') && $ticket->relationLoaded('agent')) {
return;
}
@@ -81,7 +81,6 @@ final class WorkflowNotificationService
if ($userIds->isEmpty()) {
$ticket->setRelation('user', null);
$ticket->setRelation('owner', null);
$ticket->setRelation('agent', null);
return;
@@ -96,7 +95,6 @@ final class WorkflowNotificationService
$agent = $ticket->agent_id === null ? null : $users->get((int) $ticket->agent_id);
$ticket->setRelation('user', $owner);
$ticket->setRelation('owner', $owner);
$ticket->setRelation('agent', $agent);
}
@@ -105,7 +103,7 @@ final class WorkflowNotificationService
return match ($role) {
'agent' => $ticket->agent,
'actor' => $actor,
default => $ticket->owner,
default => $ticket->user,
};
}
@@ -119,7 +117,7 @@ final class WorkflowNotificationService
'{{ ticket.category }}' => (string) ($ticket->category?->name ?? ''),
'{{ ticket.project }}' => (string) ($ticket->project?->title ?? ''),
'{{ ticket.team }}' => (string) ($ticket->team?->name ?? ''),
'{{ requester.name }}' => (string) ($ticket->owner?->name ?? ''),
'{{ requester.name }}' => (string) ($ticket->user?->name ?? ''),
'{{ agent.name }}' => (string) ($ticket->agent?->name ?? ''),
'{{ actor.name }}' => (string) ($actor?->name ?? ''),
'{{ ticket.url }}' => route('helpdesk.tickets.show', ['ticket' => $ticket->getKey()]),