first
This commit is contained in:
26
app/Policies/CommentPolicy.php
Normal file
26
app/Policies/CommentPolicy.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\ProjectComment;
|
||||
use App\Models\TranscriptionProject;
|
||||
use App\Models\User;
|
||||
|
||||
class CommentPolicy
|
||||
{
|
||||
public function view(User $user, TranscriptionProject $project): bool
|
||||
{
|
||||
return $project->isAccessibleBy($user);
|
||||
}
|
||||
|
||||
public function create(User $user, TranscriptionProject $project): bool
|
||||
{
|
||||
return $project->isAccessibleBy($user);
|
||||
}
|
||||
|
||||
public function delete(User $user, ProjectComment $comment): bool
|
||||
{
|
||||
$project = $comment->project;
|
||||
return $comment->user_id === $user->id || $project->isOwnedBy($user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user