An open API service indexing awesome lists of open source software.

https://github.com/statix-php/sentra

A lightweight Laravel roles and permissions package using Backed Enums
https://github.com/statix-php/sentra

laravel permissions roles roles-permissions

Last synced: about 1 month ago
JSON representation

A lightweight Laravel roles and permissions package using Backed Enums

Awesome Lists containing this project

README

          

# Sentra for Laravel

[![Latest Version on Packagist](https://img.shields.io/packagist/v/statix/sentra.svg?style=flat-square)](https://packagist.org/packages/statix/sentra)

A lightweight Laravel roles and permissions package using Backed Enums.

## Installation

You can install the package via composer:

```bash
composer require statix/sentra
```

You should publish the config file with the following command:

```bash
php artisan vendor:publish --tag="sentra"
```

This is the contents of the published config file:

```php
return [

/**
* The backed enum class that will be used to define your roles.
*/
'roles_enum' => 'App\Enums\Roles',

/**
* The backed enum class that will be used to define your permissions.
*/
'permissions_enum' => 'App\Enums\Permissions',

];
```

## Usage

To get started, create two string backed Enums - one of your roles and one for your permissions.

```bash
php artisan make:enum "App\Enums\Roles" --string
php artisan make:enum "App\Enums\Permissions" --string
```

If you create your enums in a different namespace or different name, be sure to update the `roles_enum` and `permissions_enum` in the `sentra.php` config file.

Then add the `AsRole` trait to your `Roles` enum.

```php