ReferralNotification.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Notifications;
  3. use App\Models\User;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Notifications\Notification;
  6. class ReferralNotification extends Notification
  7. {
  8. use Queueable;
  9. /**
  10. * @var User
  11. */
  12. private $user;
  13. /**
  14. * Create a new notification instance.
  15. *
  16. * @param User $user
  17. */
  18. public function __construct(int $user, int $ref_user)
  19. {
  20. $this->user = User::findOrFail($user);
  21. $this->ref_user = User::findOrFail($ref_user);
  22. }
  23. /**
  24. * Get the notification's delivery channels.
  25. *
  26. * @param mixed $notifiable
  27. * @return array
  28. */
  29. public function via($notifiable)
  30. {
  31. return ['database'];
  32. }
  33. /**
  34. * Get the array representation of the notification.
  35. *
  36. * @param mixed $notifiable
  37. * @return array
  38. */
  39. public function toArray($notifiable)
  40. {
  41. return [
  42. 'title' => __('Someone registered using your Code!'),
  43. 'content' => '
  44. <p>You received '.config('SETTINGS::REFERRAL::REWARD').' '.config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME').'</p>
  45. <p>because '.$this->ref_user->name.' registered with your Referral-Code!</p>
  46. <p>Thank you very much for supporting us!.</p>
  47. <p>'.config('app.name', 'Laravel').'</p>
  48. ',
  49. ];
  50. }
  51. }