New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

lomkit/laravel-access-control

A Laravel package that declares in one control who can see and change each Eloquent model: its perimeters drive the policies, the query scopes and the Scout searches.
22,471 5
Install
composer require lomkit/laravel-access-control
Latest Version:v0.7.0
PHP:^8.2
Laravel:12 · 13
Older releases:11
License:MIT
Last Updated:Nov 15, 2026
Links: GitHub  ·  Packagist
Maintainer: GautierDele

Social Card of Laravel Access Control

Laravel Access Control

Laravel Access Control allows you to fully secure your application in two key areas: Policies and Queries. Manage everything in one place!

Requirements

PHP 8.2+ and Laravel 12+

Documentation, Installation, and Usage Instructions

See the documentation for detailed installation and usage instructions.

What it does

You first need to define the perimeters concerned by your applications (php artisan make:perimeter, in app/Access/Perimeters).

Create the model control (php artisan make:control). Controls are discovered in app/Access/Controls:

class PostControl extends Control
{
    protected string $model = Post::class;

    protected function perimeters(): array
    {
        return [
            GlobalPerimeter::new()
                ->allowed(function (Model $user, string $method) {
                    return $user->can(sprintf('%s global models', $method));
                })
                ->should(function (Model $user, Model $model) {
                    return true;
                })
                ->query(function (Builder $query, Model $user) {
                    return $query;
                }),
            ClientPerimeter::new()
                ->allowed(function (Model $user, string $method) {
                    return $user->can(sprintf('%s client models', $method));
                })
                ->should(function (Model $user, Model $model) {
                    return $model->client()->is($user->client);
                })
                ->query(function (Builder $query, Model $user) {
                    return $query->where('client_id', $user->client->getKey());
                }),
            // ...
        ];
    }
}

Add the HasControl trait to your model, it resolves the control whose $model matches:

class Post extends Model
{
    use HasControl;
}

Then set up your policy:

class PostPolicy extends ControlledPolicy
{
    protected string $control = PostControl::class;
}

and you are ready to go !

App\Models\Post::controlled()->get() // Apply the Control to the query

$user->can('view', App\Models\Post::first()) // Check if the user can view the post according to the policy

A controlled query run without an authenticated user returns no rows.

Related Packages

artisanpack-ui/rbac

Role-based access control for Laravel — roles with hierarchy, permissions, Blade...

6,989 0
shiwuhao/laravel-rbac

A modern Laravel 12+ RBAC package with data permissions and auto-sync features.

1,933 1
sinemacula/laravel-authorization

Role-based access control and IAM-style policy evaluation for Laravel

1,277 0
salvatorecervone/filterbymodel

Package Laravel per la gestione dei filtri di sicurezza perimetrale basati sui m...

70 1

Version History

Version Released PHP Laravel License
v0.7.0 ^8.2 ^12.0|^13.0 MIT
v0.6.0 ^8.2 ^12.0|^13.0 MIT
v0.5.0 ^8.2 ^11.0|^12.0|^13.0 MIT
v0.4.1 ^8.2 ^11.0|^12.0|^13.0 MIT
v0.4.0 ^8.2 ^11.0|^12.0|^13.0 MIT