PHP code example of marcelodelgado / filament-announcements

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

    

marcelodelgado / filament-announcements example snippets


use Marcelodelgado\Announcements\AnnouncementsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            AnnouncementsPlugin::make()
                ->pollingInterval('120s') // optional, default: '60s'
        );
}

use Marcelodelgado\Announcements\Traits\HasAnnouncements;

class User extends Authenticatable
{
    use HasAnnouncements;
}

// config/announcements.php

// Using a Laravel Gate:
'permission_check' => 'manage-announcements',

// Using a closure:
'permission_check' => fn ($user) => $user->hasRole('admin'),

// Using Spatie Permission:
'permission_check' => fn ($user) => $user->can('manage-announcements'),
bash
php artisan vendor:publish --tag="announcements-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="announcements-config"
php artisan vendor:publish --tag="announcements-views"
php artisan vendor:publish --tag="announcements-translations"
bash
php artisan vendor:publish --tag="announcements-translations"