diff --git a/app/Http/Controllers/TicketController.php b/app/Http/Controllers/TicketController.php index 6d8345e..ba79824 100644 --- a/app/Http/Controllers/TicketController.php +++ b/app/Http/Controllers/TicketController.php @@ -70,7 +70,8 @@ class TicketController extends Controller }); }); } - $tickets = $tickets->where('status', ($request->st==TicketStatus::archived()) ? '=' : '<>', TicketStatus::archived()); + $tickets = $tickets->where('status', ($request->status == TicketStatus::archived()) ? + '=' : '<>', TicketStatus::archived()); if ($request->search) { $tickets = $this->searchTicket($tickets, $request); } diff --git a/app/Models/Message.php b/app/Models/Message.php index 93467ce..4d533e6 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -41,8 +41,16 @@ class Message extends Model } // ? Is message author is admin ? if ($messageUser->isAdmin()) { - $ticket->subscriptions()->attach($messageUser); - \session()->flash('info', trans('Vous avez été inscrit.')); + // TODO: investigate why this make errors on prod, + // https://supportweb.ldc.fr/ticket/583/message/create + // SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '583-8' for key 'PRIMARY' + // $ticket->subscriptions()->attach($messageUser); + + // Add subscription + if (!$messageUser->subscriptions()->find($ticket->id)) { + $messageUser->subscriptions()->attach($ticket->id); + \session()->flash('info', trans('Vous avez été inscrit.')); + } } // * Send mail to other subscribed users event(new NotifySubscriptions(