Package

Kyrch Laravel Prohibitions

Prohibit your models from execute an action in a way similar to spatie/laravel-permission.

Package

kyrch/laravel-prohibitions

View on GitHub →

Prohibit your models

Description

Laravel Prohibitions is a Laravel package that allows you to prohibit users from executing specific actions for a determined period of time.

Instead of relying on hard-coded checks or ad-hoc flags, this package introduces a sanction-based system where actions can be explicitly denied through well-defined rules.

The package also provides a Sanction model, which works as a preset of prohibited actions, making it easy to group multiple prohibitions under a single disciplinary rule — such as temporary bans, feature restrictions, or full account suspensions.

Installation

You can install the package via composer:

composer require kyrch/laravel-prohibitions

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-prohibitions-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-prohibitions-config"

Usage

Setup

Add the HasSanctions trait to your User model:

use Kyrch\Prohibition\Traits\HasSanctions;

class User extends Authenticatable
{
    use HasSanctions;
}

You need to create your sanctions and prohibitions first. For example:

$prohibition = Prohibition::query()->create(['name' => 'update post']);

$sanction = Sanction::query()->create(['name' => 'posts']);

$prohibition->sanctions()->attach($sanction);
How to prohibit

Now you can use methods this packages provides, such as:

# Prohibit the user from updating any posts.
$user->prohibit('update post', now()->addWeek());

# Similar to roles, you can create a kind of "ban preset" that has a group of prohibitions.
$user->applySanction('posts', now()->addWeek());

# Check if user is prohibited from updating any post.
$user->isProhibitedFrom('update post');

It is recommended to use the isProhibitedFrom() method in your Gate::before or the before method in your policy class.

Events

There are two events: ModelProhibitionTriggered and ModelSanctionTriggered. If you don't want them enabled, you can disable it in the published config file.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Kyrch Laravel Prohibitions Related Articles

Restrict User Actions with Time-Based Sanctions Using Laravel Prohibitions image

Restrict User Actions with Time-Based Sanctions Using Laravel Prohibitions

Read article
Singleton and Scoped Container Attributes in Laravel 12.21 image

Singleton and Scoped Container Attributes in Laravel 12.21

Read article
2019 in Review image

2019 in Review

Read article
80 Laravel Tutorials, Packages, and Resources from 2016 image

80 Laravel Tutorials, Packages, and Resources from 2016

Read article
90 Laravel Tutorials, Packages, and Resources from 2023 image

90 Laravel Tutorials, Packages, and Resources from 2023

Read article
Laravel News 2025 Recap image

Laravel News 2025 Recap

Read article

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing