My user model has different roles which have inheritance relationship between each other, for example: admin is a child of superadmin.
I am trying to drop this relationship on my routes in order to organize them and avoid routes like:
Route::group(['namespace' => 'Admin\MultiDispatch', 'middleware' => ['auth.jwt:superadmin|admin']], function () {
});
I moved every role routes into files Admin.php & SuperAdmin.php
and required the files in routes.php:
/*ADMIN ROLES*/
Route::group(['middleware' => ['auth.jwt:admin']], function () {
require base_path('routes/roles/Admin.php');
});
/*SUPERADMIN ROLES */
Route::group(['middleware' => ['auth.jwt:superadmin']], function () {
require base_path('routes/roles/SuperAdmin.php');
});
and in superadmin.php I required Admin.php file again as superadmin should extend all admin routes:
<?php
require base_path('routes/roles/Admin.php');
But it seems that the endpoints that exist in Admin.php are only available to superadmin access.
is there another way to implement the inheritance concept in routes file except mention superadmin in admin routes?
/*ADMIN ROLES*/
Route::group(['middleware' => ['auth.jwt:admin,superadmin']], function () {
require base_path('routes/roles/Admin.php');
});
especially my tree is long and there are so many roles under admin