PHP code example of backstage / filament-mails

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

    

backstage / filament-mails example snippets


use Backstage\FilamentMails\Facades\FilamentMails;

public function panel(Panel $panel): Panel
{
    return $panel
        ->routes(fn () => FilamentMails::routes());
}

use Backstage\FilamentMails\FilamentMailsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(FilamentMailsPlugin::make());
}

use Backstage\FilamentMails\FilamentMailsPlugin;
use Illuminate\Support\Facades\Auth;

$panel
    ->plugins([
        FilamentMailsPlugin::make()
            ->canManageMails(function () {
                $user = Auth::user();

                // Allow access for users with specific roles
                if ($user->hasRole('admin') || $user->hasRole('supervisor')) {
                    return true;
                }

                // Allow access for users with specific permissions
                if ($user->hasPermissionTo('manage mails')) {
                    return true;
                }

                // Restrict access for all other users
                return false;
            }),
    ]);

use Backstage\FilamentMails\FilamentMailsPlugin;
use Backstage\FilamentMails\Facades\FilamentMails;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(FilamentMailsPlugin::make())
        ->tenantRoutes(fn() => FilamentMails::routes());
}

return [
    'resources' => [
        'mail' => \App\Filament\Resources\MailResource::class,
        'event' => \App\Filament\Resources\EventResource::class,
        'suppression' => \App\Filament\Resources\SuppressionResource::class
    ],
];
bash
php artisan vendor:publish --tag="mails-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="mails-config"
php artisan vendor:publish --tag="filament-mails-config"
bash
php artisan vendor:publish --tag="filament-mails-views"