search with country
Some checks are pending
deploy / deploy (push) Waiting to run

This commit is contained in:
2024-01-03 20:44:19 +01:00
parent 597f9c111f
commit fbcc3226fe
5 changed files with 48 additions and 11 deletions

View File

@@ -24,14 +24,18 @@ class IkeaProducts extends Model
*/
public $incrementing = false;
protected function search($item)
protected function search($item,$country = '')
{
if (strlen($item) >= 2 && strlen($item) <= 5) {
return $this->where('name', 'LIKE', $item . '%')->get();
if (strlen($item) >= 2 && strlen($item) < 5) {
$result = $this->where('name', 'LIKE', $item . '%');
if ($country != '') $result = $result->where('country',$country);
return $result->get();
} else if (strlen($item >= 5)) {
return $this->where('typeName', 'LIKE', '%' . $item . '%')->orWhere('name', 'LIKE', '%' . $item . '%')->get();
} else {
return [];
if ($country != '') $result = $this->where('country',$country);
$result = $result->where(function ($query) use ($item) { $query->where('typeName', 'LIKE', '%' . $item . '%')->orWhere('name', 'LIKE', '%' . $item . '%'); } );
return $result->get();
}
}