26 lines
559 B
PHP
26 lines
559 B
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\ArtworkComment;
|
|
use App\Models\User;
|
|
|
|
class ArtworkCommentPolicy
|
|
{
|
|
/**
|
|
* Users can update their own comments.
|
|
*/
|
|
public function update(User $user, ArtworkComment $comment): bool
|
|
{
|
|
return $user->id === (int) $comment->user_id;
|
|
}
|
|
|
|
/**
|
|
* Users can delete their own comments; admins can delete any comment.
|
|
*/
|
|
public function delete(User $user, ArtworkComment $comment): bool
|
|
{
|
|
return $user->id === (int) $comment->user_id || $user->is_admin;
|
|
}
|
|
}
|