I have created policy (RelationPolicy), and add method view:
public function view(User $user, Relation $relation)
{
return $user->id === $relation->user_id;
}
And then I have tried to use it with controller helper:
$relation = Relation::where('name', '=', $name)->first();
$this->authorize('view', $relation);
But it always give me "FALSE".
When I add dd($user->id) and dd($relation->user_id) add in the policy I get those id's:
dd($user->id): 1
dd($relation->user_id): "1"
How to solve this?