= 2 && $field == "name") || (strlen($text) > 3 && $field == 'typeName') || (strlen($text) == 8 && $field == 'code')) { $result = $this->where($field, 'LIKE', '%' . $text . '%'); if ($country != '') { $result->where('country', $country); } return $result->get(); } else if ($field == "all") { if (preg_match("/0[0-9]+/", $text)) { $result = $this->where("code", '=',$text); $result->where('country', $country); } else { if (strlen($text) < 2) return []; $result = $this; $result = $this->where(function ($query) use ($text) { if (strlen($text) >= 2) $query->where("name", 'LIKE', '%'. $text . '%'); if (strlen($text) > 3) $query->orWhere("typeName", 'LIKE', '%'. $text . '%'); }); if ($country != '') { $result->where('country', $country); } } return $result->get(); } return []; } protected function multisearch($codes, $countries) { //$countries = $ // return $this->where('code',$codes)->where('country',$countries); } }