<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shafiulnaeem / multi-auth-role-permission example snippets
Route::middleware('check.auth:{your-guard}')->group(function () {
// users can access this block routes after login
Route::middleware('permission:{your-guard}')->group(function () {
// user can access this block routes if user logged in and if user have permission
// demo route
Route::group(['prefix' => 'test', 'as' => 'test.'], function () {
Route::get('/index', function () {
return response()->json([
'code' => 200,
'success' => true,
'message' => 'Permission testing',
'data' => [],
'errors' => []
]);
})->name('index');
});
});
});
Route::middleware('check.auth:admin')->group(function () {
// users can access this block routes after login
Route::middleware('permission:admin')->group(function () {
// user can access this block routes if user logged in and if user have permission
// demo routes
Route::group(['prefix' => 'test', 'as' => 'test.'], function () {
Route::get('/admin/dashboard', function () {
return response()->json([
'code' => 200,
'success' => true,
'message' => 'Admin Permission testing',
'data' => [],
'errors' => []
]);
})->name('admin.dashboard');
});
});
});
Route::middleware('check.auth:customer')->group(function () {
// users can access this block routes after login
Route::middleware('permission:customer')->group(function () {
// user can access this block routes if user loggedin and if user have permission
// demo routes
Route::group(['prefix' => 'test', 'as' => 'test.'], function () {
Route::get('/profile', function () {
return response()->json([
'code' => 200,
'success' => true,
'message' => 'Customer Permission testing',
'data' => [],
'errors' => []
]);
})->name('customer.profile');
});
});
});
use Shafiulnaeem\MultiAuthRolePermission\Http\Controllers\RolePermissionController;
Route::get('permission/module/{guard}', [RolePermissionController::class, 'module_permission'])->name('permission.route.list');
use Shafiulnaeem\MultiAuthRolePermission\Http\Controllers\RolePermissionController;
Route::group(['prefix' => 'role', 'as' => 'role.'], function () {
// use `guard` params for gurad wise role list
// use `search` params for search role
Route::get('/list', [RolePermissionController::class, 'index'])->name('list');
Route::post('/create', [RolePermissionController::class, 'store'])->name('create');
Route::get('/show/{id}', [RolePermissionController::class, 'show'])->name('show');
Route::put('/update/{id}', [RolePermissionController::class, 'update'])->name('update');
Route::delete('/delete/{id}', [RolePermissionController::class, 'destroy'])->name('delete');
});
use Shafiulnaeem\MultiAuthRolePermission\Http\Controllers\RolePermissionController;
Route::post('/user/permission/list', [RolePermissionController::class, 'get_user_permission_list'])->name('user.permission.list');
use Shafiulnaeem\MultiAuthRolePermission\Http\Controllers\RolePermissionController;
Route::post('/user/permission/add', [RolePermissionController::class, 'user_permission'])->name('user.permission.add');
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.