PHP code example of anselmokossa / filament-changelog
1. Go to this page and download the library: Download anselmokossa/filament-changelog 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/ */
anselmokossa / filament-changelog example snippets
use Filament\Changelog\ChangelogPlugin;
public function panel(Panel $panel): Panel
{
return $panel->plugin(ChangelogPlugin::make());
}
ChangelogPlugin::make()
// Navigation
->navigationLabel('What\'s new') // string|Closure|null
->navigationIcon('heroicon-o-sparkles') // string|BackedEnum|Closure|null
->activeNavigationIcon('heroicon-s-sparkles')
->navigationGroup('Docs') // string|UnitEnum|Closure|null
->navigationSort(1) // int|Closure|null
->registerNavigation(true) // bool|Closure — show a nav item at all
// Labels
->modelLabel('release note') // string|Closure|null
->pluralModelLabel('release notes') // string|Closure|null
// Reader page
->perPage(8) // int|Closure|null — cards per infinite-scroll step
->searchable(true) // bool|Closure|null — show the search box
->filterableByVersion(true) // bool|Closure|null — show the version filter
// Formatting
->dateFormat('d M Y') // string|Closure|null — release-date badge format
->changeTypes(['added', 'fixed']) // array|Closure|null — types + render order
// Source (see "Reader source & file path" below)
->source('database') // 'database' | 'file'
->file('CHANGELOG.md') // string|Closure|null — local path or remote URL
->fromFile('CHANGELOG.md') // shortcut: source('file') + file(...)
->fromUrl('https://…/CHANGELOG.md') // shortcut for a remote file
->remoteCacheTtl(300) // int|Closure|null — cache seconds for a remote URL (0 = off)
// Authorization (see "Authorization" below)
->canManage(fn ($user) => $user?->hasRole('admin')) // bool|Closure|null — null defers to the policy
->policy(\App\Policies\ChangelogEntryPolicy::class) // string|Closure|null — policy bound to the model
// Routing & data
->slug('changelog') // string|Closure|null — reader page route slug
->resourceSlug('changelog/manage') // string|Closure|null — management route slug
->multiProject(false); // bool|Closure|null — scope entries by a "project" column
// 1) A simple gate — block everyone, or decide per user:
ChangelogPlugin::make()
->canManage(fn ($user) => $user?->hasRole('admin'));
// 2) Do nothing and it defers to the model's policy / Gate —
// so Filament Shield permissions work out of the box:
// php artisan shield:generate → ViewAny/Create/Update/Delete are enforced.