Skip to content

Commit

Permalink
fixed #1533
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Jul 15, 2020
1 parent a067866 commit bd07382
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions app/Abstracts/Http/Controller.php
Expand Up @@ -44,16 +44,20 @@ public function setPermissions()

$controller = '';

// Add module
if (isset($arr[3]) && isset($arr[4])) {
if (strtolower($arr[4]) == 'modules') {
$controller .= Str::kebab($arr[3]) . '-';
} elseif (isset($arr[5]) && (strtolower($arr[5]) == 'modules')) {
$controller .= Str::kebab($arr[4]) . '-';
}
}

// Add folder
if (strtolower($arr[1]) != 'controllers') {
$controller .= Str::kebab($arr[1]) . '-';
}

// Add module
if (isset($arr[3]) && isset($arr[4]) && (strtolower($arr[4]) == 'modules')) {
$controller .= Str::kebab($arr[3]) . '-';
}

// Add file
$controller .= Str::kebab($arr[0]);

Expand All @@ -63,6 +67,11 @@ public function setPermissions()
return;
}

// App\Http\Controllers\FooBar -->> foo-bar
// App\Http\Controllers\FooBar\Main -->> foo-bar-main
// Modules\Blog\Http\Controllers\Posts -->> blog-posts
// Modules\Blog\Http\Controllers\Portal\Posts -->> blog-portal-posts

// Add CRUD permission check
$this->middleware('permission:create-' . $controller)->only('create', 'store', 'duplicate', 'import');
$this->middleware('permission:read-' . $controller)->only('index', 'show', 'edit', 'export');
Expand Down

0 comments on commit bd07382

Please sign in to comment.