Skip to content

Commit

Permalink
add default policies to allow all actions on permissions and roles
Browse files Browse the repository at this point in the history
  • Loading branch information
vyuldashev committed Aug 28, 2018
1 parent 19fd704 commit 57f3a04
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/PermissionPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace Vyuldashev\NovaPermission;

use Illuminate\Auth\Access\HandlesAuthorization;

class PermissionPolicy
{
use HandlesAuthorization;

public function viewAny(): bool
{
return true;
}

public function view(): bool
{
return true;
}

public function create(): bool
{
return true;
}

public function update(): bool
{
return true;
}

public function delete(): bool
{
return true;
}

public function restore(): bool
{
return true;
}

public function forceDelete(): bool
{
return true;
}
}
47 changes: 47 additions & 0 deletions src/RolePolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace Vyuldashev\NovaPermission;

use Illuminate\Auth\Access\HandlesAuthorization;

class RolePolicy
{
use HandlesAuthorization;

public function viewAny(): bool
{
return true;
}

public function view(): bool
{
return true;
}

public function create(): bool
{
return true;
}

public function update(): bool
{
return true;
}

public function delete(): bool
{
return true;
}

public function restore(): bool
{
return true;
}

public function forceDelete(): bool
{
return true;
}
}
4 changes: 4 additions & 0 deletions src/ToolServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Vyuldashev\NovaPermission;

use Gate;
use Laravel\Nova\Nova;
use Laravel\Nova\Events\ServingNova;
use Illuminate\Support\ServiceProvider;
Expand All @@ -26,6 +27,9 @@ public function boot()
$this->routes();
});

Gate::policy(config('permission.models.permission'), PermissionPolicy::class);
Gate::policy(config('permission.models.role'), RolePolicy::class);

Nova::serving(function (ServingNova $event) {
//
});
Expand Down

0 comments on commit 57f3a04

Please sign in to comment.