Skip to content

Commit

Permalink
Update policy code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
drbyte committed Sep 19, 2024
1 parent a2965a4 commit a6cfb37
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/best-practices/using-policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PostPolicy
{
use HandlesAuthorization;

public function view(?User $user, Post $post)
public function view(?User $user, Post $post): bool
{
if ($post->published) {
return true;
Expand All @@ -42,12 +42,12 @@ class PostPolicy
return $user->id == $post->user_id;
}

public function create(User $user)
public function create(User $user): bool
{
return ($user->can('create posts'));
}

public function update(User $user, Post $post)
public function update(User $user, Post $post): bool
{
if ($user->can('edit all posts')) {
return true;
Expand All @@ -58,7 +58,7 @@ class PostPolicy
}
}

public function delete(User $user, Post $post)
public function delete(User $user, Post $post): bool
{
if ($user->can('delete any post')) {
return true;
Expand Down

0 comments on commit a6cfb37

Please sign in to comment.