I have the following authorization defined in my controller:
$this->authorize('store', $cart);
In my store method on my cart policy I have the following statement:
public function store(User $user, Cart $cart)
{
// Check if cart is owned by user
if ($user->id != $cart->user_id ) {
dd($cart);
return response()->view('errors.404');
}
// Some other checks
return true
}
But I get the following error: HttpException in AuthorizesRequests.php line 94
The error appears to be thrown when trying to evaluate the if statement because when I change comparison operator to ==
no error is thrown. I've determined this by using dd().
// Check if cart is owned by user
if ($user->id == $cart->user_id ) {
dd($cart);
return response()->view('errors.404');
}
Any one have any ideas why this unusual behavior
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire