### Install Filament Alerts Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Install the package via Composer and run the installation command. ```bash composer require tomatophp/filament-alerts ``` ```bash php artisan filament-alerts:install ``` -------------------------------- ### Implement Custom Notification Driver Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Create a custom driver by extending the Driver abstract class and implementing the setup and sendIt methods. ```php $model, 'modelId' => $modelId, 'title' => $title, 'body' => $body, 'url' => $url, 'icon' => $icon, 'type' => $type, 'action' => $action, 'data' => $data, 'template_id' => $template_id, ])); } else { foreach ($model::all() as $user) { dispatch(new NotifyDatabaseJob([ 'model_type' => $model, 'modelId' => $user->id, 'title' => $title, 'body' => $body, 'url' => $url, 'icon' => $icon, 'type' => $type, 'action' => $action, 'data' => $data, 'template_id' => $template_id, ])); } } } } ``` -------------------------------- ### Run Queue Worker Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Start the queue worker to process notifications. ```bash php artisan queue:work ``` -------------------------------- ### Format code style Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Runs the code formatter to ensure compliance with project style guidelines. ```bash composer format ``` -------------------------------- ### Publish Package Assets Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Use Artisan commands to publish specific package assets to your application. ```bash php artisan vendor:publish --tag="filament-alerts-config" ``` ```bash php artisan vendor:publish --tag="filament-alerts-views" ``` ```bash php artisan vendor:publish --tag="filament-alerts-lang" ``` ```bash php artisan vendor:publish --tag="filament-alerts-migrations" ``` -------------------------------- ### Run PEST tests Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Executes the test suite using the PEST testing framework. ```bash composer test ``` -------------------------------- ### Register Infolist Entries Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Extend the notifications template infolist by registering new entries. ```php use TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Infolist\NotificationsTemplateInfoList; public function boot() { NotificationsTemplateInfoList::register([ \Filament\Infolists\Components\TextEntry::make('something') ]); } ``` -------------------------------- ### Send Notification via Facade Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Send a notification using the FilamentAlerts facade. ```php use TomatoPHP\FilamentAlerts\Facades\FilamentAlerts; FilamentAlerts::notify(User::first()) ->template($template->id) ->title([ "find-text" => "change with this" ]) ->body([ "find-text" => "change with this" ]) ->send(); ``` -------------------------------- ### Register Form Components Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Extend the notifications template form by registering new components. ```php use TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Form\NotificationsTemplateForm; public function boot() { NotificationsTemplateForm::register([ \Filament\Forms\Components\TextInput::make('something') ]); } ``` -------------------------------- ### Run PHPStan analysis Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Performs static analysis on the codebase using PHPStan. ```bash composer analyse ``` -------------------------------- ### Register Custom Notification Action Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Define a custom action using the NotificationAction class within the service provider boot method. ```php use TomatoPHP\FilamentAlerts\Facades\FilamentAlerts; public function boot() { FilamentAlerts::register( \TomatoPHP\FilamentAlerts\Services\Concerns\NotificationAction::make('system') ->label('System') ->color('primary') ->icon('heroicon-o-bell') ); } ``` -------------------------------- ### Register Custom Driver Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Register the custom driver within the boot method of your service provider using the FilamentAlerts facade. ```php use TomatoPHP\FilamentAlerts\Facades\FilamentAlerts; public function boot() { FilamentAlerts::register( \TomatoPHP\FilamentAlerts\Services\Concerns\NotificationDriver::make('database') ->label('Database') ->color('primary') ->icon('heroicon-o-bell') ->driver(\TomatoPHP\FilamentAlerts\Services\Drivers\DatabaseDriver::class) ); } ``` -------------------------------- ### Enable Email Settings Hub Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Add this method to the plugin configuration to enable SMTP settings management directly from the GUI. ```php ->plugin(\TomatoPHP\FilamentAlerts\FilamentAlertsPlugin::make() ->useSettingsHub() ) ``` -------------------------------- ### Register Table Bulk Actions Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Add custom bulk actions to the notifications template table. ```php use TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateBulkActions; public function boot() { NotificationsTemplateBulkActions::register([ \Filament\Tables\BulkActions\DeleteAction::make() ]); } ``` -------------------------------- ### Customize Resource Classes Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Define custom classes for tables, forms, and infolists within the package configuration file. ```php /** * --------------------------------------------- * Resource Building * --------------------------------------------- * if you want to use the resource custom class */ 'resource' => [ 'table' => [ 'class' => \TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateTable::class, 'filters' => \TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateFilters::class, 'actions' => \TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateActions::class, 'header-actions' => \TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateHeaderActions::class, 'bulkActions' => \TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateBulkActions::class, ], 'form' => [ 'class' => \TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Form\NotificationsTemplateForm::class, ], 'infolist' => [ 'class' => \TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Infolist\NotificationsTemplateInfoList::class, ] ] ``` -------------------------------- ### Register Table Columns Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Extend the notifications template table by registering new columns. ```php use TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateTable; public function boot() { NotificationsTemplateTable::register([ \Filament\Tables\Columns\TextColumn::make('something') ]); } ``` -------------------------------- ### Register Filament Alerts Plugin Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Register the plugin in your AdminPanelProvider. ```php ->plugin(\TomatoPHP\FilamentAlerts\FilamentAlertsPlugin::make() ) ``` -------------------------------- ### Register Table Actions Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Add custom actions to the notifications template table. ```php use TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateActions; public function boot() { NotificationsTemplateActions::register([ \Filament\Tables\Actions\ReplicateAction::make() ]); } ``` -------------------------------- ### Direct Notification Methods Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Send notifications directly using user model methods. ```php $user->notifyEmail(string $message, ?string $subject = null, ?string $url = null); $user->notifyDB(string $message, ?string $title=null, ?string $url =null); ``` -------------------------------- ### Register Page Actions Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Attach custom actions to specific notification template pages. ```php use TomatoPHP\FilamentAlerts\Facades\FilamentAlerts; use TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Pages\ListNotificationsTemplates; public function boot() { FilamentAlerts::registerAction(action: [ Filament\Actions\Action::make('action') ], page: ListNotificationsTemplates::class); } ``` -------------------------------- ### Register Custom Notification Type Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Use the FilamentAlerts facade within the service provider boot method to define a new notification type. ```php use TomatoPHP\FilamentAlerts\Facades\FilamentAlerts; public function boot() { FilamentAlerts::register( \TomatoPHP\FilamentAlerts\Services\Concerns\NotificationType::make('system') ->label('System') ->color('primary') ->icon('heroicon-o-bell') ); } ``` -------------------------------- ### Send Native Filament Notification Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Use the Filament native notification system with the provided macro. ```php use Filament\Notifications\Notification; Notification::make('send') ->title('Test Notifications') ->body('This is a test notification') ->icon('heroicon-o-bell') ->color('success') ->actions([ \Filament\Notifications\Actions\Action::make('view') ->label('View') ->url('https://google.com') ->markAsRead() ]) ->sendUse(auth()->user(), \TomatoPHP\FilamentAlerts\Services\Drivers\EmailDriver::class); ``` -------------------------------- ### Register Table Filters Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Add custom filters to the notifications template table. ```php use TomatoPHP\FilamentAlerts\Filament\Resources\NotificationsTemplateResource\Table\NotificationsTemplateFilters; public function boot() { NotificationsTemplateFilters::register([ \Filament\Tables\Filters\SelectFilter::make('something') ]); } ``` -------------------------------- ### Enable Notifications on Model Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Add the InteractsWithNotifications trait to your User model. ```php label('User') ->color('primary') ->icon('heroicon-o-bell') ); } ``` -------------------------------- ### Hide Notification Resources Source: https://github.com/tomatophp/filament-alerts/blob/master/README.md Configure the plugin to hide notification resources from the sidebar. ```php ->plugin(\TomatoPHP\FilamentAlerts\FilamentAlertsPlugin::make() ->hideNotificationsResources() ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.