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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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
同一列上的Laravel_Laravel_Eloquent - Fatal编程技术网

同一列上的Laravel

同一列上的Laravel,laravel,eloquent,Laravel,Eloquent,如何使用Laravel雄辩地查询以下内容: ->where('items.type',"shirt") ->where('items.type',"glass") 我需要获得衬衫和玻璃 以上内容适用于同一列中的1。如果我将第二个放置在(玻璃)处,则不会返回任何内容 我想要的查询,如SQL: WHERE items.type == "shirt" || items.type == "gass" 使用或where方法 ->where('items.type', 'shirt')

如何使用Laravel雄辩地查询以下内容:

->where('items.type',"shirt")
->where('items.type',"glass")
我需要获得衬衫玻璃

以上内容适用于同一列中的1。如果我将第二个放置在(玻璃)处,则不会返回任何内容

我想要的查询,如SQL:

WHERE items.type == "shirt" || items.type == "gass"

使用
或where
方法

->where('items.type', 'shirt')->orWhere('items.type', 'glass')
->whereIn('items.type', ['shirt', 'glass'])
它被记录在

您可以将where约束链接在一起,也可以向查询中添加
子句。
orWhere
方法接受与
where
方法相同的参数:

您还可以使用
方法,其中
方法

->where('items.type', 'shirt')->orWhere('items.type', 'glass')
->whereIn('items.type', ['shirt', 'glass'])
方法验证给定列的值是否包含在给定数组中:


使用
或where
方法

->where('items.type', 'shirt')->orWhere('items.type', 'glass')
->whereIn('items.type', ['shirt', 'glass'])
它被记录在

您可以将where约束链接在一起,也可以向查询中添加
子句。
orWhere
方法接受与
where
方法相同的参数:

您还可以使用
方法,其中
方法

->where('items.type', 'shirt')->orWhere('items.type', 'glass')
->whereIn('items.type', ['shirt', 'glass'])
方法验证给定列的值是否包含在给定数组中:


如果你想要一个或条件,你应该把它包装在一个where

->where(function($query){
   $query->where('items.type',"shirt")->whereOr('items.type',"glass");
});


如果你想要一个或条件,你应该把它包装在一个where

->where(function($query){
   $query->where('items.type',"shirt")->whereOr('items.type',"glass");
});


如果是hasManyThrough关系,则必须执行->whereHas('items.type','shirt'),->whereHas('items.type','glass')或item.type是列的名称?如果是hasManyThrough关系,则必须执行->whereHas('items.type','shirt'),->whereHas('items.type','glass')或item.type是列的名称?