This commit is contained in:
2024-01-06 17:08:33 +01:00
parent 9f9420643e
commit e4eec833a9
6 changed files with 100 additions and 42 deletions

View File

@@ -24,22 +24,21 @@ class IkeaProducts extends Model
*/
public $incrementing = false;
protected function search($item,$country = '')
protected function search($field, $text, $country)
{
if (strlen($item) >= 2 && strlen($item) < 5) {
$result = $this->where('name', 'LIKE', $item . '%');
if ($country != '') $result = $result->where('country',$country);
if ((strlen($text) >= 2 && $field == "name") || (strlen($text) > 3 && $field == 'typeName')) {
$result = $this->where($field, 'LIKE', '%' . $text . '%');
if ($country != '') {
$result->where('country', $country);
}
return $result->get();
} else if (strlen($item >= 5)) {
$result = $this->where(function ($query) use ($item) { $query->where('typeName', 'LIKE', '%' . $item . '%')->orWhere('name', 'LIKE', '%' . $item . '%'); } );
if ($country != '') $result = $result->where('country',$country);
return $result->get();
}
return [];
}
protected function multisearch($codes, $countries) {
protected function multisearch($codes, $countries)
{
//$countries = $
// return $this->where('code',$codes)->where('country',$countries);
}