sarmadict / filament-kit
Filament panel styling, localized resources, related-record links and model concerns for Laravel admin panels.
Requires
- php: ^8.3
- filament/filament: ^5.10
- laravel/framework: ^12.0 || ^13.0
Requires (Dev)
- orchestra/testbench: ^10.0 || ^11.0
- phpunit/phpunit: ^11.5 || ^12.5
Suggests
- laravel/boost: Install the bundled filament-kit-development skill for your coding agents.
- spatie/laravel-settings: Persist settings edited through the optional SettingsPage base class.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-28 01:22:03 UTC
README
Shared admin panel styling, localized resource pages, related-record links, audit tracking and role-based policy helpers for Filament 5.10+, Laravel 12 or 13, and PHP 8.3+.
Install
composer require sarmadict/filament-kit
In an application with a Filament panel, Laravel package discovery applies the kit automatically. The panel gets a searchable, collapsible sidebar, full-width layout, blue/zinc palette, unsaved-change alerts and transactional actions. The Blade render hooks load the kit's CSS, JavaScript and translations from the installed package. A standard Filament installation can use all of these with its existing theme.
The panel provider can override the defaults and supply its own font, logo or Vite theme. To choose individual panels, create config/filament-kit.php with return ['auto_register_plugin' => false]; and add ->plugin(\Sarmadict\FilamentKit\FilamentKitPlugin::make()) to each selected panel.
Build a resource
Extend Sarmadict\FilamentKit\Resources\LocalizedResource and use the kit's Resources\Pages\CreateRecord, EditRecord and ViewRecord for its pages. Set the resource's $model and $translationKey. For a key of articles, define the entity's labels in the host translations at admin.resources.articles.singular and admin.resources.articles.plural.
public static function form(Schema $schema): Schema { return $schema->columns(1)->components([ static::stateToggle(), static::formColumns( main: [ static::formSection(__('admin.sections.article'))->schema([ TextInput::make('title')->required(), Select::make('author_id') ->relationship('author', 'name') ->live() ->hintAction(static::relatedRecordAction('author_id', Author::class)), ]), ], sidebar: [static::auditSection()], ), ]); }
The grid uses a 9/3 desktop split and stacks on mobile. Pass mainColumnSpan: 8 for an 8/4 split. Edit and create pages put the form actions in the header. Tables open the accessible record page, sort by descending primary key and show 50 rows by default.
Use the related resource's authorized destination for relationship columns. Keep their relationships eager-loaded.
TextColumn::make('author.name') ->url(fn (Article $record) => static::relatedRecordUrl($record->author)) ->openUrlInNewTab()
A link goes to edit when permitted, then falls back to view. Records without an accessible destination keep their display text. Use relatedRecordEntry() for a read-only relationship and relatedRecordsEntry() alongside a multiple selector.
Models and settings
- State. Add
Sarmadict\FilamentKit\Models\Concerns\HasStateto the model, define itsstatecolumn, and cast it toSarmadict\FilamentKit\Enums\State. New models default to enabled. Query enabled rows withModel::enabled(). - Audit. Add
Models\Concerns\HasCreatorAndUpdaterand nullablecreated_byandupdated_byforeign keys for the actor. Authenticated creates and updates stamp those fields. The audit panel uses the model from Laravel'susersprovider, or the sole configured authentication model. For a separate admin model, setfilament-kit.audit_user_modelto its class. - Settings. Extend
Sarmadict\FilamentKit\Pages\SettingsPage, implementsettingsClass()andschema(), and set the page's navigation group in the host. The settings object must implementtoArray(),fill()andsave(), as provided by Spatie Laravel Settings. Access uses the host'sadmin.access,settings.viewandsettings.updategates. Save rechecks authorization. - Bulk deletion. In apps that authorize each selected row through the individual delete or force-delete policy, call
Sarmadict\FilamentKit\Actions\AuthorizeBulkDeletion::perRecord()from the application service provider'sboot(). This opts the application into fetching each selected model and using its policy for bulk deletion, including read-only relation manager checks.
English and Persian strings ship with the package. To customize one, Laravel supports a namespaced override such as lang/vendor/filament-kit/fa/navigation.php under the application's configured language directory.
Role-based permissions
To use the kit's optional ACL, register Sarmadict\FilamentKit\Authorization\AclServiceProvider in your application's bootstrap/providers.php. The application supplies its user, role and permission models and their tables.
- Have the user implement
Authorization\PermissionActorand useAuthorization\Concerns\CanAuthorizeandHasRole. Return the host role model class fromprotected function getRoleModel(): string. - Use
Authorization\Concerns\HasPermissionon the role. Return the permission model class fromprotected function getPermissionModel(): string. Each permission has aname. The traits use arole_userpivot withuser_idandrole_id, and apermissiblemorph pivot withpermissible_type,permissible_id,permission_id,assigned_byandassigned_at. - Extend
Authorization\ResourcePolicyin a concrete model policy and set itsprotected string $permissionPrefixto a plural kebab-case identifier. A policy with a prefix ofmedia-fileschecksmedia-files.updatefor edits. The gate registrar allows exact grants and lets Laravel evaluate a policy when a role has no matching grant.
Coding agent skill
The package includes the filament-kit-development skill under resources/boost/skills. In a Laravel Boost project, run php artisan boost:install --skills and select this package. The skill covers page layout, linking relationships in lists and forms, media selections, model conventions and policy naming.
Development
Run composer install and composer test with PDO SQLite enabled. The tests use an isolated Laravel application. To consume a local clone before publishing, add a Composer repository with "type": "vcs" and "url" pointing to its Git directory, then require the tagged version as usual.
MIT licensed. See LICENSE.