Code:
$best_price = DB::select('Some SQL statement');
foreach($best_price as $best_price_id) {
$best_price_id->id;
};
$product->best_price_id = $best_price_id;
return $product->best_price_id;
Result:
The Response content must be a string or object implementing __toString(), "object" given.
Definately I am retrieving information from the DB incorrectly. Please suggest better option.
The function to which return $product->best_price_id; is returning value is expecting string and you are supplying an object, You need to do
product->best_price_id = $best_price_id->id;
in place of product->best_price_id = $best_price_id;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.