composer require rupadana/filament-announce
php artisan make:notifications-table # Laravel 11+
php artisan migrate
app/Providers/Filament/AdminPanelProvider.php:
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
\Rupadana\FilamentAnnounce\FilamentAnnouncePlugin::make(),
]);
}
php artisan make:filament-announce --name="Welcome Back" --message="New features are live!"
Or manually via the Filament UI (accessible under the configured navigation group).Creating Announcements:
can_access middleware).// Programmatic creation (e.g., in a service)
\Rupadana\FilamentAnnounce\Models\Announce::create([
'title' => 'Breaking News',
'message' => 'API updates scheduled for tomorrow.',
'is_published' => true,
]);
Displaying Announcements:
is_published = true.user_id field to show announcements to specific users.Announce model to add custom visibility rules (e.g., role-based):
public function isVisibleTo(User $user)
{
return $user->hasRole('premium') && $this->is_published;
}
Integration with Filament Pages:
AnnounceResource:
use Rupadana\FilamentAnnounce\Resources\AnnounceResource;
public static function getPages(): array
{
return [
'index' => Pages\ListAnnounces::route('/'),
'create' => Pages\CreateAnnounce::route('/create'),
// ...
];
}
Scheduling:
schedules to auto-publish announcements:
$schedule->call(function () {
\Rupadana\FilamentAnnounce\Models\Announce::where('scheduled_at', now())
->update(['is_published' => true]);
})->daily();
resources/views/vendor/filament-announce/announce.blade.php) for multi-language support.Route::get('/api/announcements', function () {
return \Rupadana\FilamentAnnounce\Models\Announce::published()->get();
});
event(new \Rupadana\FilamentAnnounce\Events\AnnounceCreated($announce));
Navigation Group Misconfiguration:
navigation.group in config/filament-announce.php matches your Filament panel’s sidebar group.group to an existing sidebar group (e.g., 'content').Permission Denied:
can_access middleware defaults to super_admin. Override in config or extend the AnnouncePolicy:
// app/Policies/AnnouncePolicy.php
public function viewAny(User $user)
{
return $user->hasRole(['admin', 'editor']);
}
Migration Conflicts:
notifications:table twice may cause errors. Delete the notifications table manually if needed.--force with migrations cautiously; back up first.Stale Cache:
php artisan filament:cache-clear
Announce model:
public function debugVisibility(User $user)
{
return [
'is_published' => $this->is_published,
'user_match' => $user->id === $this->user_id,
'custom_rules' => $this->isVisibleTo($user),
];
}
DB::enableQueryLog();
$announces = \Rupadana\FilamentAnnounce\Models\Announce::published()->get();
dd(DB::getQueryLog());
Custom Fields:
Add fields to the announces table via a migration:
Schema::table('announces', function (Blueprint $table) {
$table->string('color')->default('#4CAF50');
$table->boolean('is_urgent')->default(false);
});
Then extend the AnnounceResource to include these fields.
Event Listeners: Listen for announcement creation to trigger side effects (e.g., Slack notifications):
// app/Providers/EventServiceProvider.php
protected $listen = [
\Rupadana\FilamentAnnounce\Events\AnnounceCreated::class => [
\App\Listeners\NotifySlack::class,
],
];
Testing: Use Filament’s testing helpers to assert announcement visibility:
$this->actingAs($user)
->get('/admin/announces')
->assertSee('Welcome Back');
created_at DESC by default. Override in the AnnounceResource:
public static function getSortableFields(): array
{
return [
'priority' => fn (Announce $record) => $record->priority ?? 0,
];
}
php artisan vendor:publish --tag="filament-announce-views" --force
How can I help you explore Laravel packages today?