PHP code example of laravel-notification-channels / discord
1. Go to this page and download the library: Download laravel-notification-channels/discord library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laravel-notification-channels / discord example snippets
// ...
use NotificationChannels\Discord\DiscordChannel;
use NotificationChannels\Discord\DiscordMessage;
class GameChallengeNotification extends Notification
{
public $challenger;
public $game;
public function __construct(Guild $challenger, Game $game)
{
$this->challenger = $challenger;
$this->game = $game;
}
public function via($notifiable)
{
return [DiscordChannel::class];
}
public function toDiscord($notifiable)
{
return DiscordMessage::create("You have been challenged to a game of *{$this->game->name}* by **{$this->challenger->name}**!");
}
}
shell
php artisan discord:setup
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.