Esempio n. 1
0
 /**
  * NotBetween
  *
  * @param $key
  * @param $value
  * @return $this
  */
 private function setNotBetween($key, $value)
 {
     if (is_array($value)) {
         $this->query->whereNotBetween($key, $value);
     }
     return $this;
 }
 /**
  * @param Builder $where
  * @param array   $filters
  * @param string  $boolean
  */
 protected static function apply(Builder $where, array $filters, $boolean)
 {
     foreach ($filters as $filterName => $valuePair) {
         foreach ($valuePair as $key => $value) {
             if (is_array($value) && count($value) > 0) {
                 $value = array_values($value);
                 if (count($value[0]) > 1) {
                     switch ($filterName) {
                         case BaseFilter::RANGES:
                             $where->whereBetween($key, [$value[0][0], $value[0][1]], $boolean);
                             break;
                         case BaseFilter::NOT_RANGES:
                             $where->whereNotBetween($key, [$value[0][0], $value[0][1]], $boolean);
                             break;
                     }
                 } else {
                     switch ($filterName) {
                         case BaseFilter::GROUP:
                             $where->whereIn($key, $value, $boolean);
                             break;
                         case BaseFilter::NOT_GROUP:
                             $where->whereNotIn($key, $value, $boolean);
                             break;
                     }
                 }
             }
             $value = (array) $value;
             $value = array_shift($value);
             switch ($filterName) {
                 case BaseFilter::GREATER_THAN_OR_EQUAL:
                     $where->where($key, '>=', $value, $boolean);
                     break;
                 case BaseFilter::GREATER_THAN:
                     $where->where($key, '>', $value, $boolean);
                     break;
                 case BaseFilter::LESS_THAN_OR_EQUAL:
                     $where->where($key, '<=', $value, $boolean);
                     break;
                 case BaseFilter::LESS_THAN:
                     $where->where($key, '<', $value, $boolean);
                     break;
                 case BaseFilter::CONTAINS:
                     $where->where($key, 'LIKE', '%' . $value . '%', $boolean);
                     break;
                 case BaseFilter::NOT_CONTAINS:
                     $where->where($key, 'NOT LIKE', '%' . $value . '%', $boolean);
                     break;
                 case BaseFilter::STARTS_WITH:
                     $where->where($key, 'LIKE', $value . '%', $boolean);
                     break;
                 case BaseFilter::ENDS_WITH:
                     $where->where($key, 'LIKE', '%' . $value, $boolean);
                     break;
                 case BaseFilter::EQUALS:
                     $where->where($key, '=', $value, $boolean);
                     break;
                 case BaseFilter::NOT_EQUAL:
                     $where->where($key, '!=', $value, $boolean);
                     break;
             }
         }
     }
 }
 /**
  * @param Builder $query
  * @param string  $field
  * @param string  $condition
  */
 protected function _query(Builder $query, $field, $condition = 'and')
 {
     $query->whereNotBetween($field, $this->getValue(), $condition);
 }