You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,12 +71,14 @@ To use this package, you need to create a notification class, like `NewsWasPubli
71
71
72
72
```php
73
73
<?php
74
+
75
+
use Illuminate\Notifications\Notification;
74
76
use NotificationChannels\Twitter\TwitterChannel;
77
+
use NotificationChannels\Twitter\TwitterMessage;
75
78
use NotificationChannels\Twitter\TwitterStatusUpdate;
76
79
77
80
class NewsWasPublished extends Notification
78
81
{
79
-
80
82
/**
81
83
* Get the notification's delivery channels.
82
84
*
@@ -88,7 +90,7 @@ class NewsWasPublished extends Notification
88
90
return [TwitterChannel::class];
89
91
}
90
92
91
-
public function toTwitter($notifiable)
93
+
public function toTwitter(mixed $notifiable): TwitterMessage
92
94
{
93
95
return new TwitterStatusUpdate('Laravel notifications are awesome!');
94
96
}
@@ -98,15 +100,15 @@ class NewsWasPublished extends Notification
98
100
Take a closer look at the `toTwitter` method. Here we define what kind of Twitter message we want to trigger. In this case, it is a status update message, which is just a new message in your timeline.
99
101
100
102
````php
101
-
public function toTwitter($notifiable)
103
+
public function toTwitter(mixed $notifiable): TwitterMessage
102
104
{
103
105
return new TwitterStatusUpdate('Laravel notifications are awesome!');
104
106
}
105
107
````
106
108
### Publish Twitter status update with images
107
109
It is possible to publish images with your status update too. You have to pass the image path to the `withImage` method.
108
110
````php
109
-
public function toTwitter($notifiable)
111
+
public function toTwitter(mixed $notifiable): TwitterMessage
110
112
{
111
113
return (new TwitterStatusUpdate('Laravel notifications are awesome!'))->withImage('marcel.png');
112
114
}
@@ -121,7 +123,7 @@ return (new TwitterStatusUpdate('Laravel notifications are awesome!'))->withImag
121
123
### Send a direct message
122
124
To send a Twitter direct message to a specific user, you will need the `TwitterDirectMessage` class. Provide the Twitter user handler as the first parameter and the the message as the second one.
123
125
````php
124
-
public function toTwitter($notifiable)
126
+
public function toTwitter(mixed $notifiable): TwitterMessage
125
127
{
126
128
return new TwitterDirectMessage('marcelpociot', 'Hey Marcel, it was nice meeting you at the Laracon.');
127
129
}
@@ -130,7 +132,7 @@ public function toTwitter($notifiable)
130
132
You can also provide the `user ID` instead of the `screen name`. This would prevent an extra Twitter API call. Make sure to pass it as an integer when you do.
131
133
132
134
````php
133
-
public function toTwitter($notifiable)
135
+
public function toTwitter(mixed $notifiable): TwitterMessage
134
136
{
135
137
return new TwitterDirectMessage(12345, 'Hey Marcel, it was nice meeting you at the Laracon.');
0 commit comments