Search by

sarmadict / filament-kit

saeidasadi

Filament panel styling, localized resources, related-record links and model concerns for Laravel admin panels.

Package info

github.com/sarmadict/filament-kit

pkg:composer/sarmadict/filament-kit

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-23 20:29 UTC

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\HasState to the model, define its state column, and cast it to Sarmadict\FilamentKit\Enums\State. New models default to enabled. Query enabled rows with Model::enabled().
  • Audit. Add Models\Concerns\HasCreatorAndUpdater and nullable created_by and updated_by foreign keys for the actor. Authenticated creates and updates stamp those fields. The audit panel uses the model from Laravel's users provider, or the sole configured authentication model. For a separate admin model, set filament-kit.audit_user_model to its class.
  • Settings. Extend Sarmadict\FilamentKit\Pages\SettingsPage, implement settingsClass() and schema(), and set the page's navigation group in the host. The settings object must implement toArray(), fill() and save(), as provided by Spatie Laravel Settings. Access uses the host's admin.access, settings.view and settings.update gates. 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's boot(). 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.

  1. Have the user implement Authorization\PermissionActor and use Authorization\Concerns\CanAuthorize and HasRole. Return the host role model class from protected function getRoleModel(): string.
  2. Use Authorization\Concerns\HasPermission on the role. Return the permission model class from protected function getPermissionModel(): string. Each permission has a name. The traits use a role_user pivot with user_id and role_id, and a permissible morph pivot with permissible_type, permissible_id, permission_id, assigned_by and assigned_at.
  3. Extend Authorization\ResourcePolicy in a concrete model policy and set its protected string $permissionPrefix to a plural kebab-case identifier. A policy with a prefix of media-files checks media-files.update for 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.