Reputation: 11
enter image description hereI was using the laravel shopping cart when I got this error. Please ask how to fixenter image description here
Upvotes: 0
Views: 324
Reputation: 233
As per your code you are trying to access data directly without checking if data is return from the query:
You need to check first:
if ($product_info) {
// do your code here
}
then redirect to your desire page
The product your are looking for is does not exist that's why you got that error.
Or else you can also use below query:
DB::table('tbl_product')->where('product_id', $productId)->firstOrFail();
The findOrFail methods will retrieve the first result of the query; however, if no result is found, a Illuminate\Database\Eloquent\ModelNotFoundException will be thrown:
Upvotes: 1