PHPackages                             mashyindustries/laraccess - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. mashyindustries/laraccess

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

mashyindustries/laraccess
=========================

Roles, Inheritence &amp; Permissions for Laravel 5.4

1.0.4(9y ago)315MITPHPPHP &gt;=5.6.0

Since Mar 30Pushed 9y agoCompare

[ Source](https://github.com/mashyindustries/laraccess)[ Packagist](https://packagist.org/packages/mashyindustries/laraccess)[ RSS](/packages/mashyindustries-laraccess/feed)WikiDiscussions 1.0.4 Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Laraccess - User Roles &amp; Role Inheritance
=============================================

[](#laraccess---user-roles--role-inheritance)

Works with Laravel 5.4

This package allows to save roles in a database. Roles can inherit other roles too.

It includes blade directives &amp; middleware

Install
-------

[](#install)

You can install the package via composer:

```
$ composer require mashyindustries/laraccess
```

This service provider must be installed.

```
// config/app.php
'providers' => [
    ...
    Mashy\Laraccess\LaraccessServiceProvider::class,
];
```

You can publish the migration with:

```
php artisan vendor:publish --provider="Mashy\Laraccess\LaraccessServiceProvider" --tag="migrations"
```

The package assumes that your users table name is called "users". If this is not the case you should manually edit the published migration to use your custom table name.

After the migration has been published you can create the role tables with:

```
php artisan migrate
```

You can publish the config-file with:

```
php artisan vendor:publish --provider="Mashy\Laraccess\LaraccessServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

First add the `Mashy\Laraccess\Traits\HasRoles` trait to your User model.

```
use Mashy\Laraccess\Traits\HasRoles;

class User
{
    use HasRoles;

    // ...
}
```

This package allows for users to be associated with roles.

You can create roles with:

```
use Mashy\Laraccess\Models\Role;

$role = Role::create([
    'name' => 'Writer', //optional
    'slug' => 'writer', //required
    'description' => '' //optional
]);
```

The `HasRoles` adds collections to your models.

```
$roles = $user->roles(); // returns a collection
```

### Using Roles

[](#using-roles)

A role can be assigned to a user:

```
$user->assignRole('writer');

// you can also assign multiple roles at once
$user->assignRole('writer', 'admin');
$user->assignRole(['writer', 'admin']);
```

A role can be removed from a user:

```
$user->removeRole('writer');
```

Roles can also be synced :

```
//all current roles will be removed from the user and replace by the array given
$user->syncRoles(['writer', 'admin']);
```

You can determine if a user has a certain role:

```
$user->hasRole('writer');
```

You can also determine if a user has any of a given list of roles:

```
$user->hasAnyRole(['writer', 'admin']);
```

You can also determine if a user has all of a given list of roles:

```
$user->hasAllRoles(['writer', 'admin']);
```

### Using blade directives

[](#using-blade-directives)

This package also adds Blade directives to verify whether the currently logged in user has all or any of a given list of roles.

```
@role('writer')
I'm a writer!
@else
I'm not a writer...
@endrole
```

```
@hasanyrole(['writer', 'admin'])
I have one or more of these roles!
@else
I have none of these roles...
@endrole
```

```
@hasallroles(['writer', 'admin'])
I have all of these roles!
@else
I don't have all of these roles...
@endrole
```

You can use Laravel's native `@can` directive to check if a user has a certain permission.

### Using a middleware

[](#using-a-middleware)

Information coming soon...

### Inheritance

[](#inheritance)

Information coming soon...

Credits
-------

[](#credits)

This package was based on [Spatie/Laravel-Permission](https://github.com/spatie/laravel-permission)

Alternatives
------------

[](#alternatives)

- [JosephSilber/bouncer](https://github.com/JosephSilber/bouncer)
- [BeatSwitch/lock-laravel](https://github.com/BeatSwitch/lock-laravel)
- [Zizaco/entrust](https://github.com/Zizaco/entrust)
- [bican/roles](https://github.com/romanbican/roles)
- [spatie/laravel-permission](https://github.com/spatie/laravel-permission)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.8% 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 ~1 days

Total

3

Last Release

3325d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f6287835255e182837792d8d1bc1a6e04d58008e7622d41e39e57f19da018906?d=identicon)[MrMashy](/maintainers/MrMashy)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (135 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (9 commits)")[![lowerends](https://avatars.githubusercontent.com/u/6588791?v=4)](https://github.com/lowerends "lowerends (4 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (4 commits)")[![peterquentin](https://avatars.githubusercontent.com/u/1672096?v=4)](https://github.com/peterquentin "peterquentin (2 commits)")[![adaojunior](https://avatars.githubusercontent.com/u/4921294?v=4)](https://github.com/adaojunior "adaojunior (2 commits)")[![knnethdw](https://avatars.githubusercontent.com/u/3512335?v=4)](https://github.com/knnethdw "knnethdw (1 commits)")[![niknetniko](https://avatars.githubusercontent.com/u/1756811?v=4)](https://github.com/niknetniko "niknetniko (1 commits)")[![nWidart](https://avatars.githubusercontent.com/u/882397?v=4)](https://github.com/nWidart "nWidart (1 commits)")[![rickselby](https://avatars.githubusercontent.com/u/1564517?v=4)](https://github.com/rickselby "rickselby (1 commits)")[![thekordy](https://avatars.githubusercontent.com/u/11343048?v=4)](https://github.com/thekordy "thekordy (1 commits)")[![tomschlick](https://avatars.githubusercontent.com/u/70184?v=4)](https://github.com/tomschlick "tomschlick (1 commits)")[![anhtuank7c](https://avatars.githubusercontent.com/u/3163410?v=4)](https://github.com/anhtuank7c "anhtuank7c (1 commits)")[![danielsdeboer](https://avatars.githubusercontent.com/u/13170241?v=4)](https://github.com/danielsdeboer "danielsdeboer (1 commits)")[![draperstudio](https://avatars.githubusercontent.com/u/257012927?v=4)](https://github.com/draperstudio "draperstudio (1 commits)")[![fahmiardi](https://avatars.githubusercontent.com/u/1201482?v=4)](https://github.com/fahmiardi "fahmiardi (1 commits)")[![kinow](https://avatars.githubusercontent.com/u/304786?v=4)](https://github.com/kinow "kinow (1 commits)")

---

Tags

laravelsecurityaclrolespermissionsinheritancelaraccessmashyindustries

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mashyindustries-laraccess/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[erag/laravel-role-permission

A simple and easy-to-install role and permission management package for Laravel, supporting versions 10.x and 11.x

404.2k](/packages/erag-laravel-role-permission)[wnikk/laravel-access-rules

Simple system of ACR (access control rules) for Laravel, with roles, groups, unlimited inheritance and possibility of multiplayer use.

103.6k1](/packages/wnikk-laravel-access-rules)

PHPackages © 2026

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