Skip to content

Commit

Permalink
Merge pull request #232 from Sebbo94BY/Add-banner-template-permissions
Browse files Browse the repository at this point in the history
Add banner template permissions
  • Loading branch information
Sebbo94BY authored Nov 20, 2023
2 parents bd82951 + 44f687d commit 6407910
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions laravel/database/seeders/PermissionSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,12 @@ public function run(): void
Permission::firstOrCreate(['name' => 'add banners']);
Permission::firstOrCreate(['name' => 'edit banners']);
Permission::firstOrCreate(['name' => 'delete banners']);

// Banner Template
Permission::firstOrCreate(['name' => 'add banner template']);
Permission::firstOrCreate(['name' => 'configure banner template']);
Permission::firstOrCreate(['name' => 'enable banner template']);
Permission::firstOrCreate(['name' => 'disable banner template']);
Permission::firstOrCreate(['name' => 'delete banner template']);
}
}
5 changes: 5 additions & 0 deletions laravel/database/seeders/RoleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public function run(): void
'add banners',
'edit banners',
'delete banners',
'add banner template',
'configure banner template',
'enable banner template',
'disable banner template',
'delete banner template',
]);
}
}
14 changes: 12 additions & 2 deletions laravel/resources/views/banner/template.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
<hr>
</div>
@can('add templates')
@can('add banner template')
<div class="container">
<div class="row">
<div class="col-lg-3">
Expand All @@ -44,7 +44,7 @@
<div class="col-lg-12">
<div class="alert alert-primary" role="alert">
{{ __('views/banner/template.no_banner_templates_added_info') }}
@can('add templates')
@can('add banner template')
<button class="btn btn-link p-0" data-bs-toggle="modal" data-bs-target="#addBannerTemplate">{{ __('views/banner/template.add_banner_template_button') }}</button>
@endcan
</div>
Expand All @@ -71,24 +71,34 @@
<td class="col-lg-1 text-end">
<div class="d-flex">
@if ($banner_template->enabled)
@can('disable banner template')
<form method="post" action="{{ route('banner.template.disable', ['banner_template_id' => $banner_template->id]) }}">
@method('patch')
@csrf
<button class="btn btn-link px-0 me-2" type="submit"><i class="fa-solid fa-toggle-on fa-lg"></i></button>
</form>
@endcan
@else
@can('enable banner template')
<form method="post" action="{{ route('banner.template.enable', ['banner_template_id' => $banner_template->id]) }}">
@method('patch')
@csrf
<button class="btn btn-link px-0 me-2" type="submit"><i class="fa-solid fa-toggle-off fa-lg"></i></button>
</form>
@endcan
@endif

@can('configure banner template')
<a href="{{ route('banner.template.configuration.edit', ['banner_template_id' => $banner_template->id]) }}" class="btn btn-link px-0 me-2"><i class="fa-solid fa-gear fa-lg"></i></a>
@endcan

@can('delete banner template')
<form method="post" action="{{ route('banner.template.remove', ['banner_template_id' => $banner_template->id]) }}">
@method('delete')
@csrf
<button class="btn btn-link px-0 me-2" type="submit"><i class="fa fa-trash text-danger fa-lg"></i></button>
</form>
@endcan
</div>
</td>
</tr>
Expand Down

0 comments on commit 6407910

Please sign in to comment.