私の製品ページには類似した商品が表示されています。表示されている製品のbrand_idまたはcat_idと似ているすべての製品を検索するクエリがあります。私の問題は、同様のセクションで表示されている現在の製品も表示することです。私はそれを作る必要があるので、類似の製品セクションから見ている現在の製品を削除します。IDは閲覧中の現在の商品IDと一致しません - Laravel 5.2
これは私が今行っている質問です。私は ********( 'ID'、 '!=='、$製品 - > IDの一部が動作していない)
/**
* Show a Product in detail
*
* @param $product_name
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show($product_name) {
// Find the product by the product name in URL
$product = Product::ProductLocatedAt($product_name);
// Select All from "products" table where the brand_id is = to the current product being viewed with its brand_id, OR where
// the category_id is = to the current product category Id being viewed. This is so we can display similar products for a // particular product being shown.
$similar_product = Product::where('brand_id', '=', $product->brand_id)
->where('id', '!==', $product->id)
->orWhere('cat_id', '=', $product->cat_id)->get();
return view('pages.show_product', compact('product', 'similar_product'));
}
******** EDITクエリメソッドを使用しているときにこれを取得する:
'!=='は有効な演算子ではありません。 '!='を試してください。 – patricus