1. Go to this page and download the library: Download blood72/laravel-jandi 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/ */
use Blood72\Jandi\Notifications\Channels\JandiWebhookChannel;
use GuzzleHttp\Client as HttpClient;
use Illuminate\Notifications\ChannelManager;
use Illuminate\Support\Facades\Notification;
// ...
Notification::resolved(function (ChannelManager $service) {
$service->extend('jandi', function ($app) {
return new JandiWebhookChannel(new HttpClient);
});
});
'jandi_webhook_url' => [
env('JANDI_WEBHOOK_URL_1'),
env('JANDI_WEBHOOK_URL_2'),
// ... and so all
],
use Blood72\Jandi\Notifications\JandiNotification;
class JandiExampleNotification extends JandiNotification
{
public function toJandi($notifiable/* = null*/): JandiMessage
{
return (new JandiMessage)->to('[email protected]')->content('hello test');
}
}
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Support\Facades\Notification;
Notification::send(new AnonymousNotifiable, new JandiExampleNotification
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class ExampleNotifiableModel extends Model
{
use Notifiable;
public function routeNotificationForJandi()
{
return 'hello routeNotificationForJandi() test';
}
}
$notifiable = new ExampleNotifiableModel;
$notification->send($notifiable, new JandiExampleNotification);
use Blood72\Jandi\Notifications\Messages\JandiMessage;
$message = JandiMessage::create('hello test');
// or $message = new JandiMessage('hello test');
Jandi::send($message);
use App\User;
public function routeNotificationForJandi()
{
return 'url';
}
// in example, $user is User model instance.
Jandi::to($user)->send('hello test');