TicketClosed.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Notifications;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Notifications\Messages\MailMessage;
  6. use Illuminate\Notifications\Notification;
  7. class TicketClosed extends Notification implements ShouldQueue
  8. {
  9. use Queueable;
  10. private $ticketId;
  11. private $title;
  12. private $url;
  13. private $reason;
  14. private $is_user;
  15. public function __construct($ticketId, $title, $url, $reason, $is_user = null)
  16. {
  17. $this->ticketId = $ticketId;
  18. $this->title = $title;
  19. $this->url = $url;
  20. $this->reason = $reason;
  21. $this->is_user = $is_user;
  22. }
  23. public function via($notifiable)
  24. {
  25. return $this->is_user ? ['mail'] : sysConfig('ticket_closed_notification');
  26. }
  27. public function toMail($notifiable)
  28. {
  29. return (new MailMessage)
  30. ->subject(trans('notification.close_ticket', ['id' => $this->ticketId, 'title' => $this->title]))
  31. ->line($this->reason)
  32. ->action(trans('notification.view_ticket'), $this->url)
  33. ->line(__('If your problem has not been solved, Feel free to open other one.'));
  34. }
  35. public function toCustom($notifiable)
  36. {
  37. return [
  38. 'title' => trans('notification.close_ticket', ['id' => $this->ticketId, 'title' => $this->title]),
  39. 'content' => $this->reason,
  40. ];
  41. }
  42. }