Php 在Laravel模型中使用和where条件
我想做的是在我的请求中使用andWherePhp 在Laravel模型中使用和where条件,php,laravel,laravel-5,Php,Laravel,Laravel 5,我想做的是在我的请求中使用andWhere $passwordreset = PasswordResets::where('token', $request->resetcode) ->andWhere('created_at','>',Carbon::now()->subHours(2))//error due to and ->first(); 但是上面返回了一个错误。我如何使用Model而不是DB:table来执行此操作,因为我希望只使用Mod
$passwordreset = PasswordResets::where('token', $request->resetcode)
->andWhere('created_at','>',Carbon::now()->subHours(2))//error due to and
->first();
但是上面返回了一个错误。我如何使用Model而不是DB:table来执行此操作,因为我希望只使用Model编写代码的标准方法
由于雄辩的模型是查询生成器,因此您应该查看查询生成器上可用的所有方法。您可以在雄辩的查询中使用这些方法中的任何一种
API参考什么错误?你能在这里展示一下吗?
$passwordreset = PasswordResets::where([
['token', $request->resetcode],
['created_at', '>', Carbon::now()->subHours(2)]
])->first();