AccountExpire.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 AccountExpire extends Notification implements ShouldQueue
  8. {
  9. use Queueable;
  10. private $days;
  11. public function __construct($expired_at)
  12. {
  13. $this->days = now()->diffInDays($expired_at);
  14. }
  15. public function via($notifiable)
  16. {
  17. return sysConfig('account_expire_notification');
  18. }
  19. public function toMail($notifiable)
  20. {
  21. return (new MailMessage)
  22. ->subject(trans('notification.account_expired'))
  23. ->line(trans('notification.account_expired_content', ['days' => $this->days]))
  24. ->action(trans('notification.view_web'), url('/'));
  25. }
  26. public function toDataBase($notifiable)
  27. {
  28. return [
  29. 'days' => $this->days,
  30. ];
  31. }
  32. public function toCustom($notifiable)
  33. {
  34. return [
  35. 'title' => trans('notification.account_expired'),
  36. 'content' => trans('notification.account_expired_content', ['days' => $this->days]),
  37. ];
  38. }
  39. }