PHP code example of nijwel / user-roles

1. Go to this page and download the library: Download nijwel/user-roles library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nijwel / user-roles example snippets

bash
php artisan migrate
bash
php artisan vendor:publish --provider="Nijwel\UserRoles\UserRoleServiceProvider"
bash
// routes/web.php

Route::get('/admin', function () {
    // Only users with the 'admin' role can access this route
})->middleware('permission:your-permission');
bash

// app/Http/Controllers/AdminController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AdminController extends Controller
{
    public function __construct()
    {
        $this->middleware('permission:your-permission');
    }

    public function index()
    {
        // Your logic here
    }
}