# 2.4 Study middleware role:admin (ok)

{% file src="https://1957079826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCBeDUD-PK_RF-YgJRe%2Fuploads%2FULqiu3UirdHWRdyKrgIz%2Ftestvn-start-study-middleware-role-admin.rar?alt=media&token=effece6b-f405-4fec-9055-ce7e32785c5d" %}

<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&#x26;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";
    });
  });
});

```
