fix search bar

This commit is contained in:
ShuriZma 2023-10-18 17:47:33 +02:00
parent f8605673ff
commit 68e6f93068
Signed by: ShuriZma
GPG Key ID: 8D289758EE9B8074
3 changed files with 6 additions and 8 deletions

View File

@ -9,7 +9,8 @@ use App\Http\Requests\StoreVehicleRequest;
use App\Http\Requests\UpdateVehicleRequest; use App\Http\Requests\UpdateVehicleRequest;
use App\Models\VehicleClass; use App\Models\VehicleClass;
use App\Models\Vendor; use App\Models\Vendor;
use Schema; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class VehicleController extends Controller class VehicleController extends Controller
{ {
@ -93,10 +94,7 @@ class VehicleController extends Controller
if ($request->has('q')) { if ($request->has('q')) {
$search = $request->q; $search = $request->q;
$games = Vehicle::select(['vehicle_name']) $games = Vehicle::select(['vehicle_name'])
->where(function ($query) use ($search) { ->where('vehicle_name', 'LIKE', "%$search%")
$query->where('name', 'LIKE', "%$search%")
->orWhere('appID', 'LIKE', "%$search%");
})
->get(); ->get();
} }

View File

@ -58,7 +58,7 @@ class Vehicle extends Model
): void { ): void {
$search = $filters['search'] ?? false; $search = $filters['search'] ?? false;
if ($search) { if ($search) {
$query->where('name', 'like', '%' . $search . '%'); $query->where('vehicle_name', 'like', '%' . $search . '%');
} }
unset($filters['search']); unset($filters['search']);

View File

@ -10,8 +10,8 @@
<h2>{{ __('Vehicles') }}</h2> <h2>{{ __('Vehicles') }}</h2>
<x-searchbar-select2 post="{{ route('vehicles') }}" inputClasses="w-[20rem]" <x-searchbar-select2 post="{{ route('vehicles') }}" inputClasses="w-[20rem]"
autocomplete="{{ route('vehicles.autocomplete') }}" autocomplete="{{ route('vehicles.autocomplete') }}"
placeholder="Select Game or AppId" templateResult="true" placeholder="Select Vehicle" templateResult="true"
templateSelection="true" text="item.name + '|AppID: ' + item.appID"> templateSelection="true" text="item.vehicle_name">
<x-select-dropdown-hover alpineVariable="vehicle_class_id" placeholder="Pick a Vehicle Class..." <x-select-dropdown-hover alpineVariable="vehicle_class_id" placeholder="Pick a Vehicle Class..."
:enums="$vehicleClasses" functionCall="getVehicleClassName"/> :enums="$vehicleClasses" functionCall="getVehicleClassName"/>
<x-select-dropdown-hover alpineVariable="brand_id" placeholder="Pick a Brand..." <x-select-dropdown-hover alpineVariable="brand_id" placeholder="Pick a Brand..."