Last active
November 8, 2022 05:00
-
-
Save chengkangzai/7205ca45231b0d0da8358ad9be4cece9 to your computer and use it in GitHub Desktop.
Policy Stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace {{ namespace }}; | |
use Illuminate\Auth\Access\HandlesAuthorization; | |
use Illuminate\Auth\Access\Response; | |
use {{ namespacedModel }}; | |
use {{ namespacedUserModel }}; | |
class {{ class }} | |
{ | |
use HandlesAuthorization; | |
public function viewAny({{ user }} $user): Response|bool | |
{ | |
return $user->can('View Any {{ model }}'); | |
} | |
public function view({{ user }} $user, {{ model }} ${{ modelVariable }}): Response|bool | |
{ | |
return $user->can('View {{ model }}'); | |
} | |
public function create({{ user }} $user): Response|bool | |
{ | |
return $user->can('Create {{ model }}'); | |
} | |
public function update({{ user }} $user, {{ model }} ${{ modelVariable }}): Response|bool | |
{ | |
return $user->can('Update {{ model }}'); | |
} | |
public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}): Response|bool | |
{ | |
return $user->can('Delete {{ model }}'); | |
} | |
public function restore({{ user }} $user, {{ model }} ${{ modelVariable }}): Response|bool | |
{ | |
return $user->can('Restore {{ model }}'); | |
} | |
public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }}): Response|bool | |
{ | |
return $user->can('Force Delete {{ model }}'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment