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!');
    }
}

App::make(Service::class)->collectNotify($user, EmailUpdatedNotification::class, []);

/**
 * The application's middleware aliases.
 *
 * Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
 *
 * @var array<string, class-string|string>
 */
protected $middlewareAliases = [
    // <...>
    'confirm.pow' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmPow::class,
    'confirm.email.input' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmEmailInput::class,
    'confirm.email.my' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmEmailMy::class,
    'confirm.phone.input' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmPhoneInput::class,
    'confirm.phone.my' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmPhoneMy::class,
    'confirm.totp.input' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmTotpInput::class,
    'confirm.totp.my' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmTotpMy::class,
    'confirm.fa.my' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmFaMy::class,
    'confirm.fa.my.dynamic' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmFaMyDynamic::class,
];
bash
php artisan vendor:publish --provider=AnourValar\\EloquentNotification\\Providers\\AnourValarEloquentNotificationServiceProvider