PHPackages                             curly-deni/laravel-permission-model-attributes - 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. [Database &amp; ORM](/categories/database)
4. /
5. curly-deni/laravel-permission-model-attributes

ActiveLibrary[Database &amp; ORM](/categories/database)

curly-deni/laravel-permission-model-attributes
==============================================

Add permission-aware attributes and static checks to Eloquent models using Laravel's authorization policies.

v1.0.1(1y ago)01221MITPHPPHP ^8.0CI passing

Since May 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/curly-deni/laravel-permission-model-attributes)[ Packagist](https://packagist.org/packages/curly-deni/laravel-permission-model-attributes)[ Docs](https://github.com/curly-deni/laravel-permission-model-attributes)[ GitHub Sponsors](https://github.com/curly-deni)[ RSS](/packages/curly-deni-laravel-permission-model-attributes/feed)WikiDiscussions main Synced today

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

Laravel Permission Model Attributes
===================================

[](#laravel-permission-model-attributes)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5ba7fc090281d67e5bcba6cb19a7ec89e939b18a6795a4698e0164a9bafbfe98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6375726c792d64656e692f6c61726176656c2d7065726d697373696f6e2d6d6f64656c2d617474726962757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/curly-deni/laravel-permission-model-attributes)[![Code Style](https://camo.githubusercontent.com/30772b380ad5e7b859f21e90392eccb2b7e17f7d832f08ef3c2ae8331a622ee7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6375726c792d64656e692f6c61726176656c2d7065726d697373696f6e2d6d6f64656c2d617474726962757465732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/curly-deni/laravel-permission-model-attributes/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/a18536ced6263179daa37ec66c769c9210ddf09c5e263eee988d5fe5da3145b4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6375726c792d64656e692f6c61726176656c2d7065726d697373696f6e2d6d6f64656c2d617474726962757465732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/curly-deni/laravel-permission-model-attributes)

**Laravel Permission Model Attributes** adds permission-aware properties to your Eloquent models using native Laravel authorization. It provides a convenient way to check and expose model-level permissions through dynamic attributes like `updatable` and `deletable`, based on policies or internal rules.

---

✨ Features
----------

[](#-features)

- ✅ Adds `updatable` and `deletable` model attributes
- 🧠 Static permission checks: `create`, `read`, `update`, `delete`
- 🔐 Seamless integration with Laravel’s native authorization system (policies)
- ⚡ Attribute caching for performance
- 🧩 Optional interface for strict typing

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require curly-deni/laravel-permission-model-attributes
```

Publish the config file:

```
php artisan vendor:publish --tag="permission-model-attributes-config"
```

---

⚙️ Configuration
----------------

[](#️-configuration)

```
return [
    'create' => true,
    'update' => true,
    'delete' => true,
    'read' => false,
];
```

Each flag enables permission checks for the corresponding action:

KeyDescriptioncreateEnables permission check via `create()` policy methodreadEnables permission check via `read()` policy methodupdateEnables permission check via `update()` policy methoddeleteEnables permission check via `delete()` policy method> ✅ Only the enabled actions will be checked. If disabled, permission checks are skipped entirely.

---

🛡 Policy Integration
--------------------

[](#-policy-integration)

The package automatically uses Laravel’s policy system. You must define policy methods **only for the enabled actions**.

### ✏ Define Policy Methods

[](#-define-policy-methods)

```
class PostPolicy
{
    public function create(User $user)
    {
        return $user->hasPermission('create-posts');
    }

    public function update(User $user, Post $post)
    {
        return $user->id === $post->user_id;
    }

    public function delete(User $user, Post $post)
    {
        return $user->id === $post->user_id;
    }

    public function read(User $user)
    {
        return $user->hasPermission('read-posts');
    }
}
```

> ⚠️ **Note:** The `read()` method accepts only the `User` object — **no model instance is passed**.

---

🚀 Usage
-------

[](#-usage)

### 1. Add the Trait

[](#1-add-the-trait)

```
use Aesis\PermissionModelAttributes\Traits\HasPermissionAttributes;

class Post extends Model
{
    use HasPermissionAttributes;
}
```

### 2. (Optional) Implement the Interface

[](#2-optional-implement-the-interface)

```
use Aesis\PermissionModelAttributes\Contracts\PermissionAttributes;

class Post extends Model implements PermissionAttributes
{
    use HasPermissionAttributes;
}
```

### 3. Access in Code

[](#3-access-in-code)

```
$post = Post::find(1);

if ($post->updatable) {
    // show edit button
}

if (Post::isCreatableStatic()) {
    // show "New" button
}
```

---

📘 Trait Reference
-----------------

[](#-trait-reference)

Method / AttributeTypeDescription`updatable`Attribute (bool)Returns `true` if the model can be updated`deletable`Attribute (bool)Returns `true` if the model can be deleted`isUpdatable()`MethodInstance-level permission check for `update``isDeletable()`MethodInstance-level permission check for `delete``isCreatableStatic()`StaticClass-level permission check for `create``isReadableStatic()`StaticClass-level permission check for `read``isUpdatableStatic()`StaticClass-level permission check for `update``isDeletableStatic()`StaticClass-level permission check for `delete`---

👤 Author
--------

[](#-author)

- [Danila Mikhalev](https://github.com/curly-deni)

---

📝 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance45

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

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

426d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/64059451?v=4)[Danila Mikhalev](/maintainers/curly-deni)[@curly-deni](https://github.com/curly-deni)

---

Top Contributors

[![curly-deni](https://avatars.githubusercontent.com/u/64059451?v=4)](https://github.com/curly-deni "curly-deni (4 commits)")

---

Tags

laravelmodeleloquentauthorizationpermissionsattributesaccess-controlPolicy

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/curly-deni-laravel-permission-model-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/curly-deni-laravel-permission-model-attributes/health.svg)](https://phpackages.com/packages/curly-deni-laravel-permission-model-attributes)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M164](/packages/spatie-laravel-health)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)

PHPackages © 2026

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