Skip to content

Commit

Permalink
Replaced Nova::resourceForModel()::uriKey() by uriKey’s functionality…
Browse files Browse the repository at this point in the history
… combined with the permission class
  • Loading branch information
dnwjn committed Sep 15, 2020
1 parent 5c5a1a9 commit 9329318
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ForgetCachedPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Laravel\Nova\Nova;
use Spatie\Permission\PermissionRegistrar;
use Illuminate\Support\Str;

class ForgetCachedPermissions
{
Expand All @@ -25,7 +26,7 @@ public function handle($request, $next)
$request->is('nova-api/*/detach') ||
$request->is('nova-api/*/*/attach*/*')
) {
$permissionKey = Nova::resourceForModel(app(PermissionRegistrar::class)->getPermissionClass())::uriKey();
$permissionKey = Str::plural(Str::kebab(class_basename(app(PermissionRegistrar::class)->getPermissionClass())));

if ($request->viaRelationship === $permissionKey) {
app(PermissionRegistrar::class)->forgetCachedPermissions();
Expand Down

0 comments on commit 9329318

Please sign in to comment.