PHPackages                             tamas1979/laravel-authority - 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. tamas1979/laravel-authority

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

tamas1979/laravel-authority
===========================

Authority / hierarchy based authorization for Laravel

v1.0.2(3w ago)07↓92.9%MITPHPPHP ^8.2

Since Jan 23Pushed 3w agoCompare

[ Source](https://github.com/Tamas1979/laravel-authority)[ Packagist](https://packagist.org/packages/tamas1979/laravel-authority)[ RSS](/packages/tamas1979-laravel-authority/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (4)Used By (0)

Laravel Authority
=================

[](#laravel-authority)

**A simple and reusable Laravel package for role hierarchy and authority-based authorization.**

This package allows you to define an **authority level** for your users and easily manage permissions between users of different levels. It works seamlessly with **API-only projects**, **Blade**, **Inertia**, or **Livewire**, and is fully **framework-agnostic**, so it can also be used alongside other permission packages like Spatie’s Roles &amp; Permissions.

---

Features
--------

[](#features)

- **Authority hierarchy**: easily compare users’ authority levels (`manage` logic built-in)
- **Reusability**: designed as a Laravel package, works across projects
- **Flexible**: integrate with any existing authorization system
- **API &amp; Blade ready**: works in controllers, policies, and views
- **Lightweight**: minimal setup, no heavy dependencies

---

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

[](#installation)

Require the package via Composer:

```
composer require tamas1979/laravel-authority
```

---

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --provider="Tamas1979\Authority\AuthorityServiceProvider" --tag=config
```

The default config:

```
return [
    'column' => 'authority_level', // the integer column in your users table
];
```

---

Setup
-----

[](#setup)

1. **Run migrations**

The package comes with a migration that adds the `authority_level` column to your `users` table. Just run:

```
php artisan migrate
```

- If the column already exists, the migration will **not overwrite it**
- No need to manually create a migration

2. **Add the Trait and implement the contract in your User model**

```
use Tamas1979\Authority\Contracts\AuthorityUser;
use Tamas1979\Authority\Traits\HasAuthority;

class User extends Authenticatable implements AuthorityUser
{
    use HasAuthority;

    protected $fillable = [
        'name',
        'email',
        'password',
        'authority_level', // required for authority logic
    ];
}
```

- The `HasAuthority` trait **must be added manually** for IDE support, type hinting, and policies to work properly
- Runtime-only usage without the trait is possible via macros, but not recommended for full type safety

3. **Authority Level Guide (example)**

Roleauthority\_levelSuperAdmin1000Owner Admin500Admin400Moderator300User100This table provides a **clear example** of how authority levels are mapped to roles.

---

Usage
-----

[](#usage)

### Tinker example

[](#tinker-example)

```
$user1 = \App\Models\User::create([
    'name' => 'Admin1',
    'email' => 'admin1@test.com',
    'password' => bcrypt('password'),
    'authority_level' => 500, // example
]);

$user2 = \App\Models\User::create([
    'name' => 'Admin2',
    'email' => 'admin2@test.com',
    'password' => bcrypt('password'),
    'authority_level' => 400, // example
]);

$user1->authorityLevel(); // 500
$user2->authorityLevel(); // 400
```

### Policy usage

[](#policy-usage)

```
$policy = new \Tamas1979\Authority\Policies\AuthorityPolicy();

$policy->manage($user1, $user2); // true
$policy->manage($user2, $user1); // false
```

### Blade / Controller

[](#blade--controller)

```
@can('manage', $targetUser)
    Remove Admin Role
@endcan
```

```
$this->authorize('manage', $targetUser);
```

---

Contribution
------------

[](#contribution)

- Open for ideas, bug fixes, and feature requests
- Supports Laravel 11, 12, and 13
- API-ready and Blade-compatible

---

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance85

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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 ~67 days

Total

3

Last Release

27d ago

### Community

Maintainers

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

---

Top Contributors

[![Tamas1979](https://avatars.githubusercontent.com/u/32540111?v=4)](https://github.com/Tamas1979 "Tamas1979 (1 commits)")

### Embed Badge

![Health badge](/badges/tamas1979-laravel-authority/health.svg)

```
[![Health](https://phpackages.com/badges/tamas1979-laravel-authority/health.svg)](https://phpackages.com/packages/tamas1979-laravel-authority)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M6](/packages/propaganistas-laravel-disposable-email)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5752.3M18](/packages/directorytree-ldaprecord-laravel)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)

PHPackages © 2026

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