> For the complete documentation index, see [llms.txt](https://learnphp.gitbook.io/learnphp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnphp.gitbook.io/learnphp/learn-lavarel/2.4-study-middleware-role-admin-ok.md).

# 2.4 Study middleware role:admin (ok)

{% file src="/files/sm72tCDn7LPVKjWBglrC" %}

<figure><img src="https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCBeDUD-PK_RF-YgJRe%2Fuploads%2F0k2eayCpqBBBc4sPbSHP%2Fimage.png?alt=media&amp;token=f1b73c3b-ca4a-468a-a93b-f6c1d752a1ea" alt=""><figcaption></figcaption></figure>

C:\xampp82\htdocs\testvn\app\Http\Kernel.php

```php
protected $routeMiddleware = [
    //    ...
    'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
  ];
```

C:\xampp82\htdocs\testvn\routes\web.php

```php
<?php
use App\Http\Controllers\BannerController;
use App\Http\Controllers\HomeController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::group(['middleware' => 'get.menu'], function () {
  Route::get('/', function () {
    return view('dashboard.homepage');
  });
  Auth::routes();
  Route::get('/home', [HomeController::class, 'index'])->name('home');
  Route::group(['middleware' => ['role:admin']], function () {
    Route::get('/test-role-admin', function () {
      echo "Hello Admin";
    });
  });
});

```
