|
@@ -3,6 +3,7 @@
|
|
namespace App\Console\Commands;
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
use App\Models\Permission;
|
|
use App\Models\Permission;
|
|
|
|
+use App\Models\PermissionGroup;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
|
|
@@ -29,6 +30,10 @@ class InitializeRoutePermission extends Command
|
|
{
|
|
{
|
|
$routes = Route::getRoutes();
|
|
$routes = Route::getRoutes();
|
|
|
|
|
|
|
|
+ $permissionGroup = PermissionGroup::query()->firstOrCreate([
|
|
|
|
+ 'name' => 'default',
|
|
|
|
+ ]);
|
|
|
|
+
|
|
foreach ($routes as $route) {
|
|
foreach ($routes as $route) {
|
|
if (! $route->getName()) {
|
|
if (! $route->getName()) {
|
|
continue;
|
|
continue;
|
|
@@ -36,7 +41,10 @@ class InitializeRoutePermission extends Command
|
|
|
|
|
|
Permission::query()->firstOrCreate([
|
|
Permission::query()->firstOrCreate([
|
|
'name' => $route->getName(),
|
|
'name' => $route->getName(),
|
|
- 'guard_name' => 'api'
|
|
|
|
|
|
+ 'guard_name' => 'api',
|
|
|
|
+ ], [
|
|
|
|
+ 'description' => $route->getName(),
|
|
|
|
+ 'permission_group_id' => $permissionGroup->id,
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|