PHP code example of tomatophp / filament-fcm
1. Go to this page and download the library: Download tomatophp/filament-fcm 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 example snippets
->plugin(\TomatoPHP\FilamentFcm\FilamentFcmPlugin::make())
use TomatoPHP\FilamentFcm\Traits\InteractsWithFCM;
class User extends Authenticatable
{
use InteractsWithFCM;
use Notifiable;
}
use Filament\Actions\Action;
use Filament\Notifications\Notification;
Notification::make('send')
->title('Test Notifications')
->body('This is a test notification')
->icon('heroicon-o-bell')
->color('success')
->actions([
Action::make('view')
->label('View')
->url('https://google.com')
->markAsRead(),
])
->sendToFCM(
user: auth()->user(),
data: [
'key' => 'value'
],
sendToDatabase: false,
type: 'fcm-web' // or fcm-api
);
$user->notifyFCMSDK(
message: 'This is a test notification',
type: 'fcm-web', // or fcm-api
title: 'Test Notifications',
url: 'https://google.com',
image: null,
icon: 'heroicon-o-bell',
data: [
'url' => 'https://google.com',
'actions' => [],
'data' => ['key' => 'value'],
],
sendToDatabase: false
);
bash
php artisan config:clear
bash
php artisan migrate
bash
php artisan filament-fcm:install
bash
php artisan vendor:publish --tag="filament-fcm-config"
bash
php artisan vendor:publish --tag="filament-fcm-views"
bash
php artisan vendor:publish --tag="filament-fcm-migrations"