Save value from TextInput for sarch
Hey, is it possible to save a value typed in a TextInput (Form) to search something? I want to build a search and want to filter some relations. How can I do this?
6 Replies
Yes you can, first you need to make TextInput::make('search')->live, then render it in your livewire view component{{ $this->form }}, in your livewire component add this
public ?array $data = [];
public function mount(): void
{
$this->form->fill();
}
then in your query do like this $products = Product::where('name', ,'like', '%' . $this->data['search'] . '%')->get();
customize form field and query logic as you need. Hope it's help!
And how can I use the
$products
with a Select::make('products')
Is there a complete example. I dont unterstand it.
@ilhamdimasprayudha
At the top
public $query = null;
TextInput::make('query')
and at the bottom
This is the error
Using $this when not in object context
Where you put TextInput::make('query')? Can I see your full code?
I want multiple checkboxes but only with attributes where I selected the group from
...