ReferralNotification.php 1.7 KB

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