Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.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/9/google-cloud-platform/3.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 关系查询或where覆盖其他where_Php_Laravel_Laravel 5_Eloquent_Laravel 5.3 - Fatal编程技术网

Php 关系查询或where覆盖其他where

Php 关系查询或where覆盖其他where,php,laravel,laravel-5,eloquent,laravel-5.3,Php,Laravel,Laravel 5,Eloquent,Laravel 5.3,案例 基于几个问题的调查,根据调查结果返回x公寓数量 公寓可以有一个固定价格(price),或一个价格范围(price\u min和price\u max)-并非所有公寓都有一个固定价格,因此它们是由价格范围定义的(例如900-1000月租金) 问题 没有或where([['price_min','!=',null],'price_max','!=',null],'price_min',''1')->where('floor','4'); } 如果($request->sun=='morning

案例

基于几个问题的调查,根据调查结果返回
x
公寓数量

公寓可以有一个固定价格(
price
),或一个价格范围(
price\u min
price\u max
)-并非所有公寓都有一个固定价格,因此它们是由价格范围定义的(例如900-1000月租金)

问题

没有
或where([['price_min','!=',null],'price_max','!=',null],'price_min',''1')->where('floor','4');
}
如果($request->sun=='morning\u sun'){
$query->where('sun','=','morning');
}elseif($request->sun=='nighlight\u sun'){
$query->where('sun','=','night');
}
如果($request->price==“1”){

$query->where('price','p>您需要对或where条件进行分组。以下操作可以实现此目的:

if ($request->price == '1') {
    $query->where(function($q) {
      $q->where('price', '<', '900')->orWhere([['price_min', '!=', null], ['price_max', '!=', null], ['price_min', '<', '900']]);
    });
} elseif ($request->price == '2') {
    $query->where(function($q) {
      $q->where('price', '<', '999')->orWhere([['price_min', '!=', null], ['price_max', '!=', null], ['price_min', '<', '999']]);
    });
}
if($request->price==“1”){
$query->where(函数($q){

$Q> >在哪里(‘价格’,‘个人’(因为我不知道LaaLVER),我会发现更容易孤立地考虑MySQL,然后留给你把这个查询转换成LaaLaveDyType是<代码> PrICEXMIN < /代码>?确保空字符串不同于NULL,所以也许应该在哪里<代码>‘Price’min’,‘!’,”“/Cuth>”。
if ($request->price == '1') {
    $query->where(function($q) {
      $q->where('price', '<', '900')->orWhere([['price_min', '!=', null], ['price_max', '!=', null], ['price_min', '<', '900']]);
    });
} elseif ($request->price == '2') {
    $query->where(function($q) {
      $q->where('price', '<', '999')->orWhere([['price_min', '!=', null], ['price_max', '!=', null], ['price_min', '<', '999']]);
    });
}