PHP code example of agp / base-utils

1. Go to this page and download the library: Download agp/base-utils 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/ */

    

agp / base-utils example snippets




namespace App\Notifications;

use Agp\BaseUtils\Notifications\PushChannel;

class ExampleNotify extends Notification
{
    use Queueable;

    private $user;
    private $mensagem;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($user, $mensagem = 'Exemplo de notificação via Push')
    {
        $this->user = $user;
        $this->mensagem = $mensagem;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [PushChannel::class];
    }

    /**
     * Get the push representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toPush($notifiable)
    {
        return [
            'notificacao' => $this->mensagem,
            'dispositivos' => $this->user->dispositivos->whereNotNull('subscricao') // Array de UsuariosDispositivos;
        ];
    }
}

bash
$ php artisan config:cache
bash
$ php artisan install:service-js
bash
$ php artisan install:service-js
bash
$ php artisan make:notification <NomeDaNotificação>