src/BaseRepository.php
public function findWhere($where, $columns = ['*'], $or = false)
    {
        $model = $this->query();

        foreach ($where as $field => $value) {

            if ($value instanceof Closure) {

                $model = ( ! $or)
                    ? $model->where($value)
                    : $model->orWhere($value);

            } elseif (is_array($value)) {

                if (count($value) === 3) {

                    list($field, $operator, $search) = $value;

                    $model = ( ! $or)
                        ? $model->where($field, $operator, $search)
                        : $model->orWhere($field, $operator, $search);

                } elseif (count($value) === 2) {

                    list($field, $search) = $value;

                    $model = ( ! $or)
                        ? $model->where($field, $search)
                        : $model->orWhere($field, $search);
                }

            } else {
                $model = ( ! $or)
                    ? $model->where($field, $value)
                    : $model->orWhere($field, $value);
            }
        }

        return $model->get($columns);
    }
public function findWhere($where, $columns = ['*'], $or = false)
    {
        $model = $this->query();

        foreach ($where as $field => $value) {

            if ($value instanceof Closure) {

                $model = ( ! $or)
                    ? $model->where($value)
                    : $model->orWhere($value);

            } elseif (is_array($value)) {

                if (count($value) === 3) {

                    list($field, $operator, $search) = $value;

                    $model = ( ! $or)
                        ? $model->where($field, $operator, $search)
                        : $model->orWhere($field, $operator, $search);

                } elseif (count($value) === 2) {

                    list($field, $search) = $value;

                    $model = ( ! $or)
                        ? $model->where($field, $search)
                        : $model->orWhere($field, $search);
                }

            } else {
                $model = ( ! $or)
                    ? $model->where($field, $value)
                    : $model->orWhere($field, $value);
            }
        }

        return $model->get($columns);
    }
public function findWhere ( $ where , $ columns = [ '*' ] , $ or = false ) { $ model = $ this -> query ( ) ; foreach ( $ where as $ field => $ value ) { if ( $ value instanceof Closure ) { $ model = ( ! $ or ) ? $ model -> where ( $ value ) : $ model -> orWhere ( $ value ) ; } elseif ( is_array ( $ value ) ) { if ( count ( $ value ) === 3 ) { list ( $ field , $ operator , $ search ) = $ value ; $ model = ( ! $ or ) ? $ model -> where ( $ field , $ operator , $ search ) : $ model -> orWhere ( $ field , $ operator , $ search ) ; } elseif ( count ( $ value ) === 2 ) { list ( $ field , $ search ) = $ value ; $ model = ( ! $ or ) ? $ model -> where ( $ field , $ search ) : $ model -> orWhere ( $ field , $ search ) ; } } else { $ model = ( ! $ or ) ? $ model -> where ( $ field , $ value ) : $ model -> orWhere ( $ field , $ value ) ; } } return $ model -> get ( $ columns ) ; }
Find a collection of models by the given query conditions.

@param  array|Arrayable $where
@param  array $columns
@param  bool  $or
@return Collection|null
Find a collection of models by the given query conditions .