PHP code example of anourvalar / eloquent-notification
1. Go to this page and download the library: Download anourvalar/eloquent-notification 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/ */
anourvalar / eloquent-notification example snippets
/**
* Route notifications for the Telegram channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string|null
*/
public function routeNotificationForTelegram($notification)
{
return $this->telegram_chatid; // set your attribute
}
/**
* Route notifications for the SMS channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string|null
*/
public function routeNotificationForSms($notification)
{
return $this->phone; // set your attribute
}
/**
* Route notifications for the Push channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string|array|null
*/
public function routeNotificationForPush($notification)
{
return $this->tokens()->orderBy('id', 'DESC')->limit(10)->pluck('push_token')->toArray(); // set your attribute
}
namespace App\Notifications\Triggers;
use Illuminate\Notifications\Messages\MailMessage;
class NewPostNotification extends \AnourValar\EloquentNotification\AbstractNotification
{
/**
* Create a new notification instance.
*/
public function __construct(public \App\Post $post)
{
parent::__construct();
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->line($this->post->title)
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
}