Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Laravel模型中使用和where条件_Php_Laravel_Laravel 5 - Fatal编程技术网

Php 在Laravel模型中使用和where条件

Php 在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

我想做的是在我的请求中使用andWhere

$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();