Redesign
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user