Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.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 如何在foreach时进行多个where查询_Php_Laravel_Eloquent - Fatal编程技术网

Php 如何在foreach时进行多个where查询

Php 如何在foreach时进行多个where查询,php,laravel,eloquent,Php,Laravel,Eloquent,我想用雄辩的口才在一个问题上提出不止一个问题。 基本上你有: <?php User::where('gender', '=', 'male')->where('age', '=', '18')->get(); ?> 你明白我的意思吗?我知道我的例子根本不可能。。但这是为了解释 谢谢大家! 您可以执行以下操作 $user = User::where('gender', 'male'); // Now add on a chain with loops or

我想用雄辩的口才在一个问题上提出不止一个问题。 基本上你有:

<?php

    User::where('gender', '=', 'male')->where('age', '=', '18')->get();

?>
你明白我的意思吗?我知道我的例子根本不可能。。但这是为了解释


谢谢大家!

您可以执行以下操作

$user = User::where('gender', 'male');

// Now add on a chain with loops or whatever expression you need.
$user = $user->where('field', 'value');

// Now get the results
$user = $user->get();

我不明白你的问题。我编辑了我的帖子,也许它会更清晰,直到我不明白。举一些真实的例子,因为很难猜出你连接对象的意思。好的,就这样,谢谢!
$user = User::where('gender', 'male');

// Now add on a chain with loops or whatever expression you need.
$user = $user->where('field', 'value');

// Now get the results
$user = $user->get();