[Vuejs]-How can I fix Laravel comments policy not working?

0👍

I just noticed that I had a commentResource and just with that I found the solution instead of checking each time on the post not directly on the comment…

class CommentResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            ...
            'can' => [
                'edit' => Auth::user()->can('update', $this->resource)
            ]
        ];
    }
}

Leave a comment