Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Acl Laravel Package

islamrumon/laravel-acl

Laravel ACL provides database-backed roles, groups, and permissions for Laravel 5.8+. Note: unmaintained since Jan 2024; consider spatie/laravel-permission instead.

View on GitHub
Deep Wiki
Context7

title: Creating a super admin weight: 5

To add a super admin to your system, you should use the global Gate::before or Gate::after rules.

Then you can just use the permission-based controls in your application, without always checking for isAdmin or anything else everywhere

Gate::before

If you want your super admin to return true for all permissions checking without assigning all permissions to that user, you should use the laravel default Gate::before method.

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
    public function boot()
    {
        $this->registerPolicies();
        
        Gate::before(fn ($user, $ability) => $user->hasGroup('Super Admin') ? true : null);
    }
}

The closure passed to Gate::before will be used before any policy gets called.

The Gate::before method needs to return null instead of false in order to not interfere with normal policy operations.

Gate::after

With Gate::after instead of Gate::before, the policies will be called first, even for superadmins.

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
    public function boot()
    {
        $this->registerPolicies();
        
        Gate::after(fn ($user, $ability) => $user->hasGroup('Super Admin'));
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle