Skip to content

Commit

Permalink
remove additional permissions from News Editor and Event Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
IsharaEkanayaka committed Jul 16, 2024
1 parent 83f732c commit de8b1c8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 41 deletions.
37 changes: 0 additions & 37 deletions database/seeders/Auth/PermissionRoleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,43 +92,6 @@ public function run()

// Assign Permissions to other Roles
//
$newsEditor = Permission::create([
'type' => User::TYPE_ADMIN,
'name' => 'admin.access.news',
'description' => 'All News Permissions',
]);

$newsEditor->children()->saveMany([
new Permission([
'type' => User::TYPE_ADMIN,
'name' => 'admin.access.news.edit',
'description' => 'Edit News',
]),
]);

$eventEditor = Permission::create([
'type' => User::TYPE_ADMIN,
'name' => 'admin.access.events',
'description' => 'All Event Permissions',
]);

$eventEditor->children()->saveMany([
new Permission([
'type' => User::TYPE_ADMIN,
'name' => 'admin.access.events.edit',
'description' => 'Edit Events',
]),
]);

// Assign permissions to the new role (News Editor)
Role::find(2)->givePermissionTo([
'admin.access.news.edit',
]);

// Assign permissions to the new role (Event Editor)
Role::find(3)->givePermissionTo([
'admin.access.events.edit',
]);

Role::find(1)->givePermissionTo([
'admin.access.user',
Expand Down
4 changes: 2 additions & 2 deletions resources/views/backend/includes/sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class="c-sidebar-nav-dropdown {{ activeClass(Route::is('admin.auth.user.*') || R
</li>
@endif

@if ($logged_in_user->hasPermissionTo('admin.access.news.edit'))
@if ($logged_in_user->hasRole('News Editor'))
{{-- News --}}
<li class="c-sidebar-nav-dropdown">
<x-utils.link href="#" icon="c-sidebar-nav-icon cil-newspaper" class="c-sidebar-nav-dropdown-toggle"
Expand All @@ -99,7 +99,7 @@ class="c-sidebar-nav-dropdown {{ activeClass(Route::is('admin.auth.user.*') || R
</li>
@endif

@if ($logged_in_user->hasPermissionTo('admin.access.events.edit'))
@if ($logged_in_user->hasRole('Event Editor'))
{{-- Events --}}
<li class="c-sidebar-nav-dropdown">
<x-utils.link href="#" icon="c-sidebar-nav-icon cil-browser" class="c-sidebar-nav-dropdown-toggle"
Expand Down
2 changes: 1 addition & 1 deletion routes/backend/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Backend\EventController;

Route::group(['middleware' => ['permission:admin.access.events.edit']], function () {
Route::group(['middleware' => ['role:Event Editor']], function () {

Route::get('/event', function () {
return view('backend.event.index');
Expand Down
2 changes: 1 addition & 1 deletion routes/backend/news.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use App\Http\Controllers\Backend\NewsController;
use Illuminate\Support\Facades\Route;

Route::group(['middleware' => ['permission:admin.access.news.edit']], function () {
Route::group(['middleware' => ['role:News Editor']], function () {

Route::get('/news', function () {
return view('backend.news.index');
Expand Down

0 comments on commit de8b1c8

Please sign in to comment.