gpt4 book ai didi

php - Laravel double 没有返回结果

转载 作者:行者123 更新时间:2023-11-29 01:19:41 25 4
gpt4 key购买 nike

我正在尝试在我的 table 上做一个双重 where,但即使参数正确我也看不到任何结果:这是我的评论模型:

class Reviews extends Model
{
protected $fillable=['id','product_id', 'user_id', 'rating', 'comment',
'approved', 'spam'];

public function user()
{
return $this->belongsTo(User::class);
}

public function product()
{
return $this->belongsTo(Product::class);
}

这是我的 Controller ,我在其中传递值并进行查询;值上的 DD 正确显示它们:

  public function storereview(Request $request){

$uid=Auth::user()->id;
$productID = $request->id;
$matchThese = ['product_id' => $productID, 'user_id' => $uid];
$result=Reviews::where($matchThese);

dd($result);

结果的DD显示: https://ibb.co/fSzRGH

我截屏了,因为我不能在这里缩进。

我做错了什么?我不明白!谢谢。

最佳答案

您需要使用 get() 来实际执行查询:

$result = Reviews::where($matchThese)->get();

关于php - Laravel double 没有返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48608156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com