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.1(3mo ago)06↓50%MITPHPPHP ^8.2

Since Jan 23Pushed 3mo 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 1mo ago

READMEChangelogDependencies (2)Versions (3)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
- Follows Laravel 11+ standards
- API-ready and Blade-compatible

---

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance79

Regular maintenance activity

Popularity5

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b8a5d6a80ef685d44147b4797440b128a301cabd7bd7f0fe5326a304858985a?d=identicon)[Tamas1979](/maintainers/Tamas1979)

### 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

[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)[pschocke/laravel-telegram-login-widget

Easily integrate Telegrams login widget into your Laravel application to send Telegram messages

1610.4k](/packages/pschocke-laravel-telegram-login-widget)

PHPackages © 2026

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