Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

agorakit/agorakit

434 stars
2 code files
View agorakit/agorakit on GitHub

app/Policies/CommentPolicy.php

Open in GitHub
use App\Comment;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization;
 
class CommentPolicy
{
public function delete(User $user, Comment $comment)
{
if ($user->isAdminOf($comment->discussion->group)) {
return true;
}
 
return $user->id === $comment->user_id;
}
 
public function history(User $user, Comment $comment)
{
return $user->isMemberOf($comment->discussion->group);
}
}

app/Http/Controllers/CommentController.php

Open in GitHub
use App\Comment;
use App\Discussion;
use App\Group;
use Illuminate\Http\Request;
 
class CommentController extends Controller
{
public function destroyConfirm(Request $request, Group $group, Discussion $discussion, Comment $comment)
{
$this->authorize('delete', $comment);
 
return view('comments.delete')
->with('discussion', $discussion)
->with('group', $group)
->with('comment', $comment)
->with('tab', 'discussion');
}
 
public function history(Request $request, Group $group, Discussion $discussion, Comment $comment)
{
$this->authorize('history', $comment);
 
return view('comments.history')
->with('group', $group)
->with('discussion', $discussion)
->with('comment', $comment)
->with('tab', 'discussion');
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.