PHPackages                             andika/tameng - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. andika/tameng

ActiveLibrary

andika/tameng
=============

Custom Filament plugin for role and permission management

1.0.0(yesterday)02↑2900%MITPHPPHP ^8.2CI failing

Since Aug 24Pushed yesterdayCompare

[ Source](https://github.com/andikarekatias/tameng)[ Packagist](https://packagist.org/packages/andika/tameng)[ Docs](https://github.com/andikarekatias/tameng)[ GitHub Sponsors](https://github.com/andika)[ RSS](/packages/andika-tameng/feed)WikiDiscussions 5.x Synced today

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

Tameng — Custom Filament authorization plugin
=============================================

[](#tameng--custom-filament-authorization-plugin)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4a11671c959516f7d9bcb38d00968e8cdd4a5fa9025dea234ba842585e6dd2bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e64696b612f74616d656e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andika/tameng)[![GitHub Tests Action Status](https://camo.githubusercontent.com/02d33495240b94f02e9b7972c9b1d96d9aa746ac1f3f296821d6de4a6693778b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616e64696b6172656b61746961732f74616d656e672f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/andikarekatias/tameng/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/2a6ca842d72babcf8a7aaafa9d304323fe6a1e2e8a80b1f21d597159156e9926/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616e64696b6172656b61746961732f74616d656e672f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/andikarekatias/tameng/actions?query=workflow%3A%22Fix+PHP+code+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c8f38c9464e44359316459703c78b79884e9bcfc940c02a2226e3c5e3727ab09/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e64696b612f74616d656e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andika/tameng)

Tameng adds role &amp; permission management to your Filament panels on top of [spatie/laravel-permission](https://github.com/spatie/laravel-permission).

### Features

[](#features)

- 🛡️ **Role Management** — manage roles and permissions from a single page with embedded permission cards
    - 📦 Resource Permissions
    - 📄 Page Permissions
    - 🧩 Widget Permissions
    - ✨ Custom Permissions
- 🤖 **Automatic Permission Generation** — scans panels and creates permissions by convention
    - 📜 Policy generation from publishable stubs
    - 🏷️ Configurable case formatting (snake, kebab, pascal, camel, upper\_snake)
    - 🔗 Entity discovery across all panels
- 👑 **Super Admin Bypass** — users with the configured role skip all authorization checks
- 🔄 **Multi-tenancy Support** — automatic tenant scoping with spatie teams + Filament panel tenancy
- 🎨 **Intuitive UI** — Shield-inspired card grid layout with icons per entity type
- ⚡ **Fine-grained CLI Tooling** — install, generate, and super-admin commands

Requirements
------------

[](#requirements)

- PHP ^8.2
- Laravel 11+
- Filament 5.x (panels)
- spatie/laravel-permission ^8.0

Installation
------------

[](#installation)

Install the package and run the installer:

```
composer require andika/tameng
php artisan tameng:install
```

The installer publishes Spatie's `config/permission.php` and the `create_permission_tables` migration, publishes our `config/tameng.php`, and asks whether you want to run `php artisan migrate`. After installation, it shows next steps:

```
tameng has been installed!

Next Steps:
  1. php artisan tameng:generate
     Generate permissions for your Filament panels
  2. php artisan tameng:super-admin user@email.com
     Assign super admin to a user
  3. php artisan permission:cache-reset
     Clear permission cache

```

Add the `HasRoles` trait to your `User` model:

```
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
}
```

Register the plugin on your panel provider:

```
use Andika\Tameng\TamengPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(TamengPlugin::make());
}
```

Usage
-----

[](#usage)

### Quickstart

[](#quickstart)

```
php artisan tameng:super-admin     # create your first admin (interactive)
php artisan tameng:generate        # permissions + policies for panel entities
php artisan permission:cache-reset # refresh the spatie cache
```

Log in at your panel's URL (e.g. `/dashboard`) — the **Tameng** navigation item appears in the sidebar. Open it to manage roles and their permissions via embedded permission cards.

### Super admin role

[](#super-admin-role)

Users with the role configured in `config/tameng.php` bypass every authorization check:

```
'super_admin' => [
    'enabled' => false,  // set to true to enable the bypass
    'name' => 'super_admin',
],
```

Set `enabled` to `true` to activate the bypass — any user with this role skips all authorization checks. The role then behaves like any other when disabled.

Assign the role from the command line:

```
php artisan tameng:super-admin
```

The command picks a panel from `--panel` (falling back to the current or the only registered panel), then:

- `--user=` — the ID of the user to promote (no prompt)
- **no users** — asks for a name, email and password and creates the user before assigning the role
- **one user** — promotes them automatically
- **multiple users** — lists them and asks for the ID to promote

```
php artisan tameng:super-admin --panel=admin --user=1
```

With spatie teams enabled, pass the team/tenant the role should be scoped to:

```
php artisan tameng:super-admin --tenant=1
```

Or do it in code:

```
Role::findOrCreate('super_admin');
$user->assignRole('super_admin');
```

### Permissions &amp; policies

[](#permissions--policies)

Generate permissions and policies for every entity registered in your panels:

```
php artisan tameng:generate
```

This creates permissions such as `user_view_any`, `user_view`, `user_create`, `user_update`, `user_delete`, `user_delete_any` and writes `app/Policies/UserPolicy.php`:

```
namespace App\Policies;

class UserPolicy
{
    public function viewAny($user): bool
    {
        return $user->can('user_view_any');
    }

    public function view($user, $model): bool
    {
        return $user->can('user_view');
    }

    // ...
}
```

Existing policies are never overwritten unless you pass `--force`:

```
php artisan tameng:generate --force
```

Generate permissions for a single panel only:

```
php artisan tameng:generate --panel=admin
```

Policies are rendered from a stub. To customize the generated policy shape, publish the stub and edit it (placeholders: `{namespace}`, `{class}`, `{methods}`):

```
php artisan vendor:publish --tag="tameng-stubs"
```

After changing permissions, refresh the permission cache:

```
php artisan permission:cache-reset
```

### Configuration

[](#configuration)

All options live in `config/tameng.php`. Publish it with:

```
php artisan vendor:publish --tag="tameng-config"
```

#### Permission builder

[](#permission-builder)

```
'permission' => [
    'separator' => '_',
    'case' => 'snake',       // snake|kebab|pascal|camel|upper_snake|lower_snake
    'generate' => true,      // false skips permission creation (policies still written)
    'name_max_length' => 255,
],
```

> **Separator + case constraint:** `_` cannot pair with snake/upper\_snake, `-` cannot pair with kebab. Examples: pascal + `:` → `User:ViewAny`; kebab + `-` → `user-view-any`.

#### Slug

[](#slug)

The URL path for the role management page. Defaults to `tameng` (e.g. `/dashboard/tameng`):

```
'slug' => 'tameng',   // → /dashboard/tameng
```

#### Excludes

[](#excludes)

Skip entities from permission generation:

```
'resources' => [
    'subject' => 'model',    // 'model' uses the resource's model class name
    'exclude' => [
        // \App\Filament\Resources\FooResource::class,
    ],
],

'pages' => [
    'exclude' => [
        \Filament\Pages\Dashboard::class,
    ],
],

'widgets' => [
    'exclude' => [
        \Filament\Widgets\AccountWidget::class,
        \Filament\Widgets\FilamentInfoWidget::class,
    ],
],
```

#### Custom permissions

[](#custom-permissions)

Extra permission keys created by `tameng:generate` alongside entity-derived permissions:

```
'custom_permissions' => [
    'system_backup',
    'audit_log',
],
```

#### Policies

[](#policies)

```
'policies' => [
    'path' => app_path('Policies'),
    'namespace' => 'App\\Policies',
    'methods' => [
        'view_any', 'view', 'create', 'update', 'delete',
        'delete_any', 'restore', 'restore_any',
        'force_delete', 'force_delete_any',
    ],
    'single_parameter_methods' => [
        'view_any', 'create', 'delete_any',
        'restore_any', 'force_delete_any',
    ],
],
```

Methods in `single_parameter_methods` generate `($user)` signatures; others generate `($user, $model)`.

Set `register_role_policy` to `true` to generate a `RolePolicy` for the spatie Role model and register it with `Gate::policy`:

```
'register_role_policy' => true,
```

#### Tenant model

[](#tenant-model)

Tameng integrates with Filament's multi-tenancy system and spatie teams. When both are enabled:

1. A `SyncTenant` middleware automatically syncs the spatie team ID from the current Filament tenant
2. The role list is scoped to the current tenant
3. New roles are automatically associated with the current tenant
4. Permission cache is only invalidated when the tenant changes

**Setup:**

1. Enable spatie teams in `config/permission.php`:

```
'teams' => true,
```

2. Set your tenant model in `config/tameng.php`:

```
'tenant_model' => App\Models\Team::class,
```

3. Register the tenant on your Filament panel:

```
use App\Models\Team;

return $panel
    ->tenant(Team::class)
    ->plugin(TamengPlugin::make());
```

4. Make your User model implement `Filament\Models\Contracts\HasTenants`:

```
use Filament\Models\Contracts\HasTenants;
use Filament\Panel;

class User extends Authenticatable implements HasTenants
{
    use HasRoles;

    public function tenants(Panel $panel): Collection
    {
        return $this->teams;
    }

    public function canAccessTenant(Model $tenant): bool
    {
        return true;
    }
}
```

5. Assign roles scoped to a tenant via CLI:

```
php artisan tameng:super-admin --user=1 --tenant=1
```

#### Entity discovery

[](#entity-discovery)

When enabled (default), `tameng:generate` scans every registered panel and generates permissions and policies for all of its resources, pages and widgets. Disable globally via config or per-panel via the plugin API:

```
'entity_discovery' => true,
```

```
TamengPlugin::make()
    ->entityDiscovery(false);   // disable for this panel only
```

#### Localization

[](#localization)

Translated permission labels in the role editor:

```
'localization' => [
    'enabled' => false,
    'key' => 'tameng::tameng.permissions',
],
```

Publish translations:

```
php artisan vendor:publish --tag="tameng-translations"
```

### Plugin configuration

[](#plugin-configuration)

Per-panel overrides via the plugin API:

```
TamengPlugin::make()
    ->superAdminRole('super_admin')   // per-panel role name override
    ->entityDiscovery(false);         // disable entity scanning in tameng:generate
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [andikarekatias](https://github.com/andikarekatias)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1d ago

Major Versions

1.0.0 → 5.x-dev2026-08-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/499832?v=4)[andika](/maintainers/andika)[@Andika](https://github.com/Andika)

---

Top Contributors

[![andikarekatias](https://avatars.githubusercontent.com/u/10099168?v=4)](https://github.com/andikarekatias "andikarekatias (3 commits)")

---

Tags

laravelfilamentfilament-pluginfilamentphpandikatameng

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/andika-tameng/health.svg)

```
[![Health](https://phpackages.com/badges/andika-tameng/health.svg)](https://phpackages.com/packages/andika-tameng)
```

###  Alternatives

[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[backstage/mails

View logged mails and events in a beautiful Filament UI.

16429.7k](/packages/backstage-mails)[althinect/filament-spatie-roles-permissions

3491.2M12](/packages/althinect-filament-spatie-roles-permissions)[marcelweidum/filament-passkeys

Use passkeys in your filamentphp app

6758.2k2](/packages/marcelweidum-filament-passkeys)[stephenjude/filament-two-factor-authentication

Filament Two Factor Authentication: Google 2FA + Passkey Authentication

85240.3k10](/packages/stephenjude-filament-two-factor-authentication)[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

16461.2k](/packages/relaticle-custom-fields)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
