Search on all fields, remove search in

This commit is contained in:
2024-03-21 08:47:30 +01:00
parent 673cd019f9
commit ea241bc5dc
2 changed files with 11 additions and 21 deletions

View File

@@ -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);
}
}

View File

@@ -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) => {
/>
</div>
</div>
<div class="">
<div>
<span class="font-extrabold font-mono">Search in:</span>
</div>
<div>
<multiselect
v-model="settingsStore.field"
:multiple="false"
:searchable="false"
:allow-empty="false"
:options="sdropdown"
track-by="value"
label="text"
@select="onSelectCode"
></multiselect>
</div>
</div>
</div>