'Trying to use Laravel policies into components
I'm trying to use Policies inside a Post Component, using Laravel. This is how I'm iterating through the posts in my page.
@foreach($posts as $post)
<x-post
:id="$post->id"
:title="$post->title"
:description="$post->description"
:userId="$post->user_id"
:img="$post->img"
:author="$post->user->name"/>
@endforeach
In the post.blade.php I'm trying to use a 'update' policy method to define which users can see the post:
@can('update', Auth::user(), /*What shoud I pass here?*/)
<a class="btn btn-success"href="{{route('posts.edit', $id)}}">
<i class="bi bi-pencil"></i>
</a>
@endcan
What should I pass as the second parameter of the policy? Normally, it would be a post variable. Since I'm already inside a post, I don't know to proceed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
