laravel-permission README

The project's README from github.com/spatie/laravel-permission. As one markdown file: README.md.

Logo for laravel-permission

Associate users with permissions and roles

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Documentation, Installation, and Usage Instructions

See the documentation for detailed instructions for how-to-use, as well as installation and upgrade guidance.

What It Does

This package allows you to manage user permissions and roles in a database.

Once installed you can do stuff like this:

// Adding permissions to a user
$user->givePermissionTo('edit articles');

// Adding permissions via a role
$user->assignRole('writer');

$role->givePermissionTo('edit articles');

Because all permissions will be registered on Laravel's gate, you can check if a user has a permission with Laravel's default can function:

$user->can('edit articles');

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Testing

composer test

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

This package is heavily based on Jeffrey Way's awesome Laracasts lessons on permissions and roles. His original code can be found in this repo on GitHub.

Special thanks to Alex Vanderbist who greatly helped with v2, and to Chris Brown for his longtime support helping us maintain the package.

Special thanks to Caneco for the original logo.

Alternatives

License

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

laravel-permission (spatie/laravel-permission)

Searching Database…

Что это?Пакет для Laravel, который позволяет управлять правами пользователей и ролями через базу данных и проверять их с помощью встроенной системы Gate в Laravel.
Это самостоятельное приложение или пакет, который я добавляю в свой проект на Laravel?Это пакет Composer, который устанавливается в существующее приложение на Laravel, а не самостоятельное приложение.
Как добавить его в свой проект на Laravel?Установите его через Composer и следуйте документации пакета по установке и обновлению (миграции, публикация конфигурации и т. д.).
Нужно ли что-то помимо самого Laravel?Нужно только приложение на Laravel с базой данных, так как роли и права хранятся там и подключаются к системе авторизации Laravel.
Как работают проверки прав после установки?Все права регистрируются в Gate Laravel, поэтому вы проверяете их стандартной функцией Laravel `can()`, а не через собственный API.
Чем это отличается от Bouncer или Laratrust?Это альтернативные пакеты прав для Laravel с другими компромиссами: Bouncer тоже хорошо зарекомендовал себя, Laratrust добавляет поддержку команд, а Entrust предлагает сопоставление по шаблону с подстановочными знаками, тогда как laravel-permission делает упор на простую модель ролей и прав в базе данных, интегрированную с Gate Laravel.
Откуда взялась идея этого пакета?Он во многом основан на уроках Jeffrey Way с Laracasts о правах и ролях, а исходный код доступен в отдельном репозитории.
Creator
spatie
Size
3.2 MB
Stars
13K
Age
11y
Commits · 90 Days