TwitterPost.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. use NotificationChannels\Twitter\TwitterChannel;
  8. use NotificationChannels\Twitter\TwitterStatusUpdate;
  9. class TwitterPost extends Notification
  10. {
  11. use Queueable;
  12. /**
  13. * Create a new notification instance.
  14. *
  15. * @return void
  16. */
  17. public function __construct()
  18. {
  19. //
  20. }
  21. /**
  22. * Get the notification's delivery channels.
  23. *
  24. * @param mixed $notifiable
  25. * @return array
  26. */
  27. public function via($notifiable)
  28. {
  29. return [TwitterChannel::class];
  30. // return ['mail'];
  31. }
  32. /**
  33. * Get the mail representation of the notification.
  34. *
  35. * @param mixed $notifiable
  36. * @return \Illuminate\Notifications\Messages\MailMessage
  37. */
  38. public function toMail($notifiable)
  39. {
  40. return (new MailMessage)
  41. ->line('The introduction to the notification.')
  42. ->action('Notification Action', url('/'))
  43. ->line('Thank you for using our application!');
  44. }
  45. /**
  46. * Get the array representation of the notification.
  47. *
  48. * @param mixed $notifiable
  49. * @return array
  50. */
  51. public function toArray($notifiable)
  52. {
  53. return [
  54. //
  55. ];
  56. }
  57. public function toTwitter($notifiable)
  58. {
  59. $text = "Calcio a 5 Anteprima - " . $notifiable->title . " " . url(env('APP_URL') . "/" . $notifiable->slug);
  60. return new TwitterStatusUpdate($text);//->withImage('marcel.png');
  61. }
  62. }