Grant permission for a new role in Laravel 5

We are developing a laravel application, the application has an administrative part, accessible only to admin users in the routesfile:

 Route::group(['middleware' => 'admin', 'prefix' => 'admin', 'namespace'
              => 'Admin'] , function() {
       Route::get('oldAdminUrl', 'oldControllwe@handle');

  }

The file descriptor function is middlewaresimilar to

public function handle($request, Closure $next)
{       
   if ($this->admin->guest())
    {
        //some code here
    }

    return $next($request);
}

ad $this->Adminrefers to Modelcalled adminModelwith the following attribute

 protected $table = 'admin'

Now we need to add a new URL to the admin URL group, to name it newAdminUrlit should be available for both admin users and a new user group by calling themeditors

URL- admin group middleware, editorsMiddleware admin middleware, , , newAdminUrl , ,

 Route::group(['middleware' => ['admin','editors], 'prefix' => 'admin',      
     'namespace' => 'Admin'] , function() {
         Route::get('newAdminUrl', 'newControllwe@handle');

   }

EditorModel, editorMiddleware, :

     protected $table = 'editor'

: ? - ?

+4
1

, , , . "", "admin" "editor" . Laravel. , __contruct() , , , .

+2

Source: https://habr.com/ru/post/1613522/


All Articles