2017 © Pedro Peláez
 

library roles

image

bu4ak/roles

  • Saturday, February 24, 2018
  • by bu4ak
  • Repository
  • 1 Watchers
  • 0 Stars
  • 176 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Very simple package with roles and middleware

Installation:

 composer require bu4ak/roles
 php artisan vendor:publish --provider="Bu4ak\Roles\RolesServiceProvider"
 ```
 modify migration if you need
 ```bash
 php artisan migrate

```php // add 'HasRoles' trait to 'User' model class User extends Authenticatable { use Notifiable, HasRoles; ..., (*1)

#### Usage example:
set `admin` (`manager` or `user`) role to user:
```php
$user = User::first();
$user->assignRole(RoleType::ADMIN);

and add middleware admin (manager or user) to route:, (*2)

Route::get('/', function () {
    return view('welcome');
})->middleware(MiddlewareType::ADMIN);

Also:

You can check user's role, (*3)

$user->isAdmin();
$user->isManager();
$user->isUser();

and select all users with a specific role, (*4)

User::admins()->get();
User::managers()->get();
User::users()->get();

The Versions

24/02 2018

dev-master

9999999-dev

  Sources   Download

MIT

by Avatar bu4ak

laravel roles

24/02 2018

dev-analysis-zEKe5O

dev-analysis-zEKe5O

  Sources   Download

MIT

by Avatar bu4ak

laravel roles