如何使用whereIn with< =?

时间:2017-02-01 09:21:55

标签: laravel laravel-5 laravel-5.2

好的我在视图中有6个复选框:

<input type="checkbox" name="rooms[]" id="room1" value="1" />1
<input type="checkbox" name="rooms[]" id="room2" value="2" />2
<input type="checkbox" name="rooms[]" id="room3" value="3" />3
<input type="checkbox" name="rooms[]" id="room4" value="4" />4
<input type="checkbox" name="rooms[]" id="room5" value="5" />5
<input type="checkbox" name="rooms[]" id="room6" value="6" />6+

用户可以检查所有这些,但是我在用户检查时遇到问题,例如,首先是值为1,最后一个值是6+。当用户检查我想要获取房间值为1且值为room >= 6的所有记录时。任何建议我怎么能这样做?

我尝试了这个但是当用户检查最后一个时这不起作用。

  $value = 6;
    if (!in_array($value, $option)) {
          $query->whereIn('rooms',$option
         }
          else{
              $query->where('rooms','>=',$value);
         }

2 个答案:

答案 0 :(得分:1)

尝试这是否适合您:

$value = 6;
if (!in_array($value, $option)) {
    $query->whereIn('rooms',$option);
}
else{
    $query->whereIn('rooms',$option)->orWhere('rooms', '>=', $value);
}

答案 1 :(得分:0)

试试这个:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for magento/product-community-edition 2.1.3 -> satisfiable by magento/product-community-edition[2.1.3].
    - magento/product-community-edition 2.1.3 requires ext-gd * -> the requested PHP extension gd is missing from your system.

  To enable extensions, verify that they are enabled in those .ini files:
    - /home/ubuntu/.phpbrew/php/php-7.0.15/etc/php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.