0

I don't understand why is it not working i neither see any errors nor any progress. Somebody please help what i am missing in my code. I already put @livewireStyles in head and @livewireScripts in script section but search functionality is not working..

<?php

namespace App\Livewire;

use App\Models\Booking;
use Livewire\Component;

class SearchUsers extends Component
{
    public $searchTerm;
    public $bookings;
    
    public function render()
    {
        $searchTerm = '%' . $this->searchTerm . '%';
        $this->bookings = Booking::where('pickup', 'like', $searchTerm)->get();

        return view('livewire.search-users');
    }
}
<input wire:model="searchTerm" type="text" placeholder="Search users..">
@php($sl = 1)
                            @forelse($bookings as $booking)
                                <tr>
                                    <td>{{$sl++}}</td>
                                    <td>{{$booking->user->name}}</td>
                                    <td>{{$booking->icabbi_trip_id}}</td>
                                    <td>{{$booking->date}}</td>
                                    <td>{{ Carbon\Carbon::createFromFormat('H:i:s', $booking->time)->format('h:i A') }}</td>
                                    <td>{{$booking->pickup}}</td>
                                    <td>{{$booking->destination}}</td>
                                    <td>{{$booking->seats}}</td>
                                    <td>{{str_replace(' ', '-', ucwords(str_replace('-', ' ', strtolower($booking->type))))}}</td>
                                    <td>{{$booking->status}}</td>
                                    <td>{{Carbon\Carbon::parse($booking->updated_at)->format('h:i A')}}</td>
                                    <td>{{$booking->cancellation_reason}}</td>
                                </tr>
                            @empty
                                <tr>
                                    <td>No bookings available</td>
                                </tr>
                            @endforelse
2
  • 1
    "I don't understand why is it not working i neither see any errors nor any progress." Okay, but what are you expecting it to do and what is currently happening? Commented Jul 22, 2024 at 16:41
  • @JayDev95 I am expected that search functionality should work but it doesn't. I am new in livewire so i don't know why it didn't working. Currently when i search nothing happens. Commented Jul 22, 2024 at 16:58

1 Answer 1

0

Found a solution to my question. I just add .live and it works:
<input wire:model.live="searchTerm" type="text" placeholder="Search users..">
instead of this
<input wire:model="searchTerm" type="text" placeholder="Search users..">

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.