Fix complex query
This commit is contained in:
@@ -41,10 +41,14 @@ class IkeaProducts extends Model
|
|||||||
if (strlen($text) < 2) return [];
|
if (strlen($text) < 2) return [];
|
||||||
$result = $this;
|
$result = $this;
|
||||||
|
|
||||||
if (strlen($text) >= 2) $result = $result->where("name", 'LIKE', '%'. $text . '%');
|
$result = $this->where(function ($query) use ($text) {
|
||||||
if (strlen($text) > 3) $result->orWhere("typeName", 'LIKE', '%'. $text . '%');
|
if (strlen($text) >= 2) $query->where("name", 'LIKE', '%'. $text . '%');
|
||||||
|
if (strlen($text) > 3) $query->orWhere("typeName", 'LIKE', '%'. $text . '%');
|
||||||
|
});
|
||||||
|
|
||||||
$result->where('country', $country);
|
if ($country != '') {
|
||||||
|
$result->where('country', $country);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $result->get();
|
return $result->get();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user