diff --git a/app/Models/IkeaProducts.php b/app/Models/IkeaProducts.php index 44ce8d7..222dcfb 100644 --- a/app/Models/IkeaProducts.php +++ b/app/Models/IkeaProducts.php @@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Model; class IkeaProducts extends Model { use HasFactory; - + protected $table = 't_ikea_products'; @@ -33,14 +33,21 @@ class IkeaProducts extends Model $result->where('country', $country); } return $result->get(); + } else if ($field == "all") { + if (preg_match("/0[0-9]+/", $text)) { + $result = $this->where("code", '=',$text); + } else + $result = $this->where("name", 'LIKE', '%'. $text . '%')->orWhere("typeName", 'LIKE', '%'. $text . '%'); + return $result->get(); } + return []; } protected function multisearch($codes, $countries) { //$countries = $ - // return $this->where('code',$codes)->where('country',$countries); + // return $this->where('code',$codes)->where('country',$countries); } } diff --git a/resources/js/Pages/IkeaRoot.vue b/resources/js/Pages/IkeaRoot.vue index f71e7c5..891eed5 100644 --- a/resources/js/Pages/IkeaRoot.vue +++ b/resources/js/Pages/IkeaRoot.vue @@ -316,8 +316,8 @@ const async_search = async () => { if (settingsStore.country.code !== undefined) country = settingsStore.country.code; console.log('SETTINGS',settingsStore.country); - console.log('URL',route("products.search", [settingsStore.field.value, settingsStore.text, country])); - const response = await axios.get(route("products.search", [settingsStore.field.value, settingsStore.text, country, settingsStore.online])); + console.log('URL',route("products.search", ['all', settingsStore.text, country])); + const response = await axios.get(route("products.search", ['all', settingsStore.text, country, settingsStore.online])); options_items.value = response.data.map((i) => { return { @@ -505,23 +505,6 @@ const selectedRowClassNameFunction = (item) => { /> -
-
- Search in: -
-
- -
-