PHP code example of tomatophp / filament-fcm-driver

1. Go to this page and download the library: Download tomatophp/filament-fcm-driver 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/ */

    

tomatophp / filament-fcm-driver example snippets


->plugin(\TomatoPHP\FilamentFcmDriver\FilamentFcmDriverPlugin::make())



namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
use TomatoPHP\FilamentFcmDriver\Traits\InteractsWithFcm;

class User extends Authenticatable
{
    use HasApiTokens;
    use HasFactory;
    use HasProfilePhoto;
    use Notifiable;
    use TwoFactorAuthenticatable;
    use HasRoles;
    use InteractsWithFcm;
    ...

use Filament\Notifications\Notification;

Notification::make()
    ->title('Test title')
    ->body('Test body')
    ->icon('heroicon-o-bell')
    ->info()
    ->sendUse($user, DiscordDriver::class);


$user->notifyFirebase(
    message: $this->message,
    type: $this->provider,
    title: $this->title,
    url: $this->url,
    image: $this->image,
    icon: $this->icon,
    data: [
        'url' => $this->url,
        'id' => $this->model_id,
        'actions' => [],
        'body' => $this->message,
        'color' => null,
        'duration' => null,
        'icon' => $this->icon,
        'iconColor' => null,
        'status' => null,
        'title' => $this->title,
        'view' => null,
        'viewData' => null,
        'data'=> $this->data
    ],
    sendToDatabase: false
);



use TomatoPHP\FilamentAlerts\Facades\FilamentAlerts;
use TomatoPHP\FilamentFcmDriver\Services\FcmWebDriver;
use TomatoPHP\FilamentFcmDriver\Services\FcmMobileDriver;

FilamentAlerts::notify($user)
    ->template($template->id)
    ->drivers([FcmWebDriver::class, FcmMobileDriver::class])
    ->title([
        'name' => $user->name,
    ])
    ->body([
        'date' => now()->toDateTimeString(),
    ])
    ->send();
bash
php artisan filament-fcm-driver:install
bash
php artisan filament-fcm:install
bash
php artisan queue:work
bash
php artisan vendor:publish --tag="filament-fcm-driver-config"
bash
php artisan vendor:publish --tag="filament-fcm-driver-views"
bash
php artisan vendor:publish --tag="filament-fcm-driver-lang"
bash
php artisan vendor:publish --tag="filament-fcm-driver-migrations"
bash
composer analyse