Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented for the to and from methods on the SlackMessage class #2687

Merged
merged 1 commit into from
Sep 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,41 @@ The example above will create a Slack message that looks like the following:

<img src="https://laravel.com/assets/img/slack-fields-attachment.png">

#### Customizing the recipient

Slack is fairly flexible, which allows us to override the custom webhook's channel by using the `to` method. This method accepts both `#channel` and `@username` notation. The latter will send the notification to a specific user.

/**
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
return (new SlackMessage)
->to('#laravel-other');
->content('This will be posted in #laravel-other')
}


#### Customizing the bot's username and icon

By default, the incoming webhook will use the default identity that you have configured in Slack, but with the `from` method it's trivial to set a custom username and icon:

/**
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
return (new SlackMessage)
->from('Ghostbot', ':ghost:');
->content('Hello from Ghostbot!')
}

<a name="routing-slack-notifications"></a>
### Routing Slack Notifications

Expand Down