PHPackages                             bunthoeuntok/laravel-simple-permission - 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. bunthoeuntok/laravel-simple-permission

ActiveLibrary

bunthoeuntok/laravel-simple-permission
======================================

Laravel simple permission package

11[3 PRs](https://github.com/bunthoeuntok/laravel-simple-permission/pulls)PHP

Since May 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bunthoeuntok/laravel-simple-permission)[ Packagist](https://packagist.org/packages/bunthoeuntok/laravel-simple-permission)[ RSS](/packages/bunthoeuntok-laravel-simple-permission/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Laravel simple permission
=========================

[](#laravel-simple-permission)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cef36f8e12395f7a744e9741862658f8ed6999dcf1082f219c03564deea04934/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62756e74686f65756e746f6b2f6c61726176656c2d73696d706c652d7065726d697373696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bunthoeuntok/laravel-simple-permission)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f0e5799f91cb1565da94645e2f2a5f4e05cb79ea1373dfb3faebecd72b316a2b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f62756e74686f65756e746f6b2f6c61726176656c2d73696d706c652d7065726d697373696f6e2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/bunthoeuntok/laravel-simple-permission/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/99cb6e00141105e7b77feb7de8e627fc17cf0405e41c1b361efd0b4f38c8b246/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f62756e74686f65756e746f6b2f6c61726176656c2d73696d706c652d7065726d697373696f6e2f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/bunthoeuntok/laravel-simple-permission/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/764337f5753fa530ff870155c0664bf33acf07f89e5f41c819a4fc5b759fb26b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62756e74686f65756e746f6b2f6c61726176656c2d73696d706c652d7065726d697373696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bunthoeuntok/laravel-simple-permission)

This package is developed to help laravel developer to implement siple role and permission.

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

[](#installation)

You can install the package via composer:

```
composer require bunthoeuntok/laravel-simple-permission
```

You can publish config, migrations and middleware by running:

```
php artisan permission:install
```

Then migrate tables by running:

```
php artisan migrate
```

This is the contents of the published config file:

```
return [
    // Menu level structure
    'menu_levels' => [
        'module',
        'sub-module',
        'page'
    ],

    // Cache key
    'cache_key' => 'permissions',

    // Menu structure to import
    'data' => [
        ...
    ]
];
```

Usage
-----

[](#usage)

### Step 1

[](#step-1)

You need to use `HasRole` trait in `User.php` model

```
use Bunthoeuntok\SimplePermission\Traits\HasRole;

class User extends Authenticatable
{
    ...
    use HasRole;
    ...
}
```

### Step 2

[](#step-2)

Register `PermissionMiddleware.php` in `Kernel.php`

```
protected $routeMiddleware = [
    ...
    'role.permission' => \App\Http\Middleware\PermissionMiddleware::class
];
```

### Step 3

[](#step-3)

Use naming route middleware in route file.

- Note: When you defined a route you should provide it with `name`, which match to route\_name in [menu action](README.md#actions).

```
// Index action
Route::get('users', [UserController::class, 'index'])->middleware(['role.psermission', 'auth'])->name('users.index');

// Delete action
Route::get('users/{user}', [UserController::class, 'destroy'])->middleware(['role.psermission', 'auth'])->name('users.destroy');
```

What we can do
==============

[](#what-we-can-do)

- Create a role and assign user a role

```
    // Create a role
    $role = Bunthoeuntok\SimplePermission\Models\Role::create([
        'role_name' => 'Admin',
        'is_admin' => false;
    ]);

    // Create user
    $user =  User::factory()->create();

    // Assign role to a user
    $user->assignRole($role);
```

actions
=======

[](#actions)

- Create menu and its actions

```
    $menu = Bunthoeuntok\SimplePermission\Models\Menu::create([
        'menu_name' => 'User',
        'level' => 'page'; // base on menu_levels in simple-permissions.php config
    ]);

    // Create menu actions
    $menu->actions()->saveMany([
        new Bunthoeuntok\SimplePermission\Models\Menu([
            'action_name' => 'index',
            'route_name' => 'modules.root-pages.index',
            'default' => true,
        ]),
        new Bunthoeuntok\SimplePermission\Models\Menu([
            'action_name' => 'delete',
            'route_name' => 'modules.root-pages.delete',
        ])
    ]);
```

- Or by running command `php artisan permission:import`, this command will import menu structure, which was set `data` key in simple-permission.php config.

```
return [
    // Menu structure to import
    'data' => [
        [
            'menu_name' => 'User',
            'level' => 'page',
            'actions' => [
                [
                    'action_name' => 'index',
                    'route_name' => 'users.index',
                    'default' => true,
                ],
                [
                    'action_name' => 'delete',
                    'route_name' => 'users.delete',
                ],
            ]
        ],
    ],
]
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Bunthoeun Tok](https://github.com/bunthoeuntok)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0839b0dfc7bf1bccf4f6b0c525916a83f202c7849f11bd049cf73c8ff3a2a449?d=identicon)[bunthoeuntok](/maintainers/bunthoeuntok)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")[![bunthoeuntok](https://avatars.githubusercontent.com/u/45479614?v=4)](https://github.com/bunthoeuntok "bunthoeuntok (3 commits)")

### Embed Badge

![Health badge](/badges/bunthoeuntok-laravel-simple-permission/health.svg)

```
[![Health](https://phpackages.com/badges/bunthoeuntok-laravel-simple-permission/health.svg)](https://phpackages.com/packages/bunthoeuntok-laravel-simple-permission)
```

PHPackages © 2026

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