PHP code example of vivalaz / laravel-route-restrict

1. Go to this page and download the library: Download vivalaz/laravel-route-restrict 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/ */

    

vivalaz / laravel-route-restrict example snippets

 artisan migrate
config/app.php

php artisan vendor:publish --provider="Vivalaz\LaravelRouteRestrict\LaravelRouteRestrictServiceProvider" --tag="migrations"

php artisan vendor:publish --provider="Vivalaz\LaravelRouteRestrict\LaravelRouteRestrictServiceProvider" --tag="config"
config/laravel-route-restrict.php

return [

    'models' => [
        'route' => Vivalaz\LaravelRouteRestrict\Models\Route::class
    ],

    'table_names' => [
        'routes' => 'routes',
        'route_for_roles' => 'route_for_roles',
        'route_for_permissions' => 'route_for_permissions'
    ]
    
];
app/Http/Kernel.php
web.php
api.php

Route::group(['middleware' => ['route_has_roles_or_permissions']], function() {
    //
});

public function __construct()
{
    $this->middleware(['route_has_roles_or_permissions']);
}