fix length win search

This commit is contained in:
2024-03-21 10:11:20 +01:00
parent ea241bc5dc
commit 103daee7fb

View File

@@ -36,8 +36,12 @@ class IkeaProducts extends Model
} else if ($field == "all") { } else if ($field == "all") {
if (preg_match("/0[0-9]+/", $text)) { if (preg_match("/0[0-9]+/", $text)) {
$result = $this->where("code", '=',$text); $result = $this->where("code", '=',$text);
} else } else {
$result = $this->where("name", 'LIKE', '%'. $text . '%')->orWhere("typeName", 'LIKE', '%'. $text . '%'); $result = $this;
if (strlen($text) >= 2) $result = $result->where("name", 'LIKE', '%'. $text . '%');
if (strlen($text) > 3) $result->orWhere("typeName", 'LIKE', '%'. $text . '%');
}
return $result->get(); return $result->get();
} }