37074-vm/app/Policies/PostPolicy.php
Flatlogic Bot c2cb4a5b67 1.0
2025-12-19 19:07:10 +00:00

73 lines
1.5 KiB
PHP

<?php
namespace App\Policies;
use App\Models\Post;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class PostPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(?User $user): bool
{
return true;
}
/**
* Determine whether the user can view the model.
*/
public function view(?User $user, Post $post): bool
{
return true;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return !!$user;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Post $post): bool
{
// In a real application, you might want to check if the user owns the post:
// return $user->id === $post->user_id;
return !!$user;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Post $post): bool
{
// In a real application, you might want to check if the user owns the post:
// return $user->id === $post->user_id;
return !!$user;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Post $post): bool
{
return !!$user;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Post $post): bool
{
return !!$user;
}
}