PHP code example of risetechapps / notify-driver-for-laravel

1. Go to this page and download the library: Download risetechapps/notify-driver-for-laravel 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/ */

    

risetechapps / notify-driver-for-laravel example snippets


return [

    'notify' => [
        'key' => env('NOTIFY_KEY', ''),
        'from_name' => env('NOTIFY_FROM_NAME', ''),
    ],

];

// app/Notifications/TestNotification.php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use RiseTechApps\Notify\Contracts\MessageContract;
use RiseTechApps\Notify\Message\MessageNotify;

class TestNotification extends Notification
{
    use Queueable;

    public function via(object $notifiable): array
    {
        return ['notify'];
    }

    public function toNotify($notifiable): MessageContract
    {
        return (new MessageNotify($notifiable))
            ->notifyEmail()
            ->subject('Test Notification')
            ->action('https://globo.com', 'Acessar Link')
            ->to('[email protected]', 'Nome do Usuário')
            ->line('Esta é uma notificação de teste.')
            ->subjectMessage('Cabeçalho da Mensagem')
            ->theme('default')
            ->content([])
            ->send();
    }
}

$user->notify(new \App\Notifications\TestNotification());

// app/Notifications/TestNotification.php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use RiseTechApps\Notify\Contracts\MessageContract;
use RiseTechApps\Notify\Message\MessageNotify;

class TestNotification extends Notification
{
    use Queueable;

    public function via(object $notifiable): array
    {
        return ['notify'];
    }

    public function toNotify($notifiable): MessageContract
    {
        return (new MessageNotify($notifiable))
            ->notifyEmail()
            ->subject('Test Notification')
            ->action('https://globo.com', 'Acessar Link')
            ->to('[email protected]', 'Nome do Usuário')
            ->line('Esta é uma notificação de teste.')
            ->subjectMessage('Cabeçalho da Mensagem')
            ->theme('default')
            ->attachFromUrl($links)
            ->content([])
            ->send();
    }
}

$user->notify(new \App\Notifications\TestNotification());

// RiseTechApps/AuthService/Notifications/Token/TokenSecuritySMS.php

namespace RiseTechApps\AuthService\Notifications\Token;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use RiseTechApps\Notify\Contracts\MessageContract;
use RiseTechApps\Notify\Message\MessageNotify;

class TokenSecuritySMS extends Notification implements ShouldQueue
{
    use Queueable;

    protected string|int $token;

    public function __construct(string|int $token)
    {
        $this->token = $token;
    }

    public function via($notifiable): array
    {
        return ['notify'];
    }

    public function toNotify($notifiable): MessageContract
    {
        return (new MessageNotify($notifiable))
            ->notifySMS()
            ->setMessage(__('Use o código para validar sua autenticação: ' . $this->token))
            ->send();
    }
}

$user->notify(new \RiseTechApps\AuthService\Notifications\Token\TokenSecuritySMS(123456));