Coder Social home page Coder Social logo

mimaxuz / role-manager Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 21 KB

Simple Laravel roles and permissions for Laravel applications

License: MIT License

PHP 100.00%
laravel-package laravel laravel-passport php7 library php laravel-roles package role database

role-manager's Introduction

Simple Role Manager

An easy and flexible Laravel authorization and roles permission management

Total Downloads

About

In many projects, you have to work with roles and permissions. Many packages are large and not all features are needed. That’s why I tried to create a small but effective package for projects. This package can be attached to any project. Convenient and efficient. It is very easy to use and can be used after installation.

Installation

However, if you are not using Homestead, you will need to make sure your server meets the following requirements:

  • PHP >= 7.2.5
  • BCMath PHP Extension
  • Ctype PHP Extension
  • Fileinfo PHP extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Install package via composer

$ composer require mimaxuz/role-manager

After that, you need to run the migration files:

$ php artisan migrate

How to use package migrations

This package includes the following tables. All tables have a relational line, and the relationships are in cascade.

Database Diagram For Laravel Role Manager packages

How to activate package ?

This package contains traits and must be activated within the App\Users model. To do this, follow the steps below.

  1. Open App\User Model and Copy the following codes
//For importing traits form package
Use MIMAXUZ\LRoles\Traits\HasPermissions;
...

class User extends Authenticatable
{
    use Notifiable;
    //Import The Trait
    use HasPermissions; 
    ...
 }

Assign a route to a role

Besides middleware and other route settings, you can use a role key in your route groups to assign a role to your routes.
You can use route groups as follows.


Route::group(['middleware' => 'role:admin'], function () {
    //With controller
    Route::get('/a', 'HomeController@dashboard');
    //Inside functions
    Route::get('/admin', function () {
        return 'Welcome Admin';
    });
});

How to use roles inside Blade ?

If you want to use it in Blade Templates, use the following.

 @role('admin')
   Only Admin roles user can access to it
 @endrole

Conclusion

This package may have issuses and bugs. Don't forget to report if an error or problem occurs!

License

Standt MIT License

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.