diff --git a/app/Models/IkeaProducts.php b/app/Models/IkeaProducts.php index 222dcfb..6d1cec9 100644 --- a/app/Models/IkeaProducts.php +++ b/app/Models/IkeaProducts.php @@ -36,8 +36,12 @@ class IkeaProducts extends Model } else if ($field == "all") { if (preg_match("/0[0-9]+/", $text)) { $result = $this->where("code", '=',$text); - } else - $result = $this->where("name", 'LIKE', '%'. $text . '%')->orWhere("typeName", 'LIKE', '%'. $text . '%'); + } else { + $result = $this; + + if (strlen($text) >= 2) $result = $result->where("name", 'LIKE', '%'. $text . '%'); + if (strlen($text) > 3) $result->orWhere("typeName", 'LIKE', '%'. $text . '%'); + } return $result->get(); }