dtqjbbr5283 2018-04-19 08:43
浏览 1118
已采纳

在Laravel中实现where子句find()

Here is my code:

public function order($id)
{
    $product = Product::find($id);
    $other_products = Product::find($id)->toArray();
    return view('products.order',['product'=>$product,'other'=>$other_products]);
}

So my question is how can i exclude $product from the $other_products query, more like SELECT * FROM table WHERE product != $id

  • 写回答

3条回答 默认 最新

  • dongxiegao3071 2018-04-19 08:44
    关注

    Use where()

    $other_products = Product::where('id', '!=', $id)->get()->toArray();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?