#2 create post
This commit is contained in:
34
app/Policies/PostPolicy.php
Normal file
34
app/Policies/PostPolicy.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Post;
|
||||
use App\Models\User;
|
||||
|
||||
class PostPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function view(User $user, Post $post): bool
|
||||
{
|
||||
return $user->id === $post->user_id;
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function update(User $user, Post $post): bool
|
||||
{
|
||||
return $user->id === $post->user_id;
|
||||
}
|
||||
|
||||
public function delete(User $user, Post $post): bool
|
||||
{
|
||||
return $user->id === $post->user_id;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user