So your livewire code and view is irrelevant,
@livewire('search',['instance'=>$event->instance, 'job'=>$event->job])
looks like $event is not passed to your view.
I have a problem with Dynamic Cascading Dropdown with Livewire. I'm basically creating a table that is filtered based on two parameters:
Component:
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Task;
class Search extends Component
{
public $poll;
public $type_poll;
public $type_polls;
public $tasks;
public $polls;
public function mount($poll,$type_poll)
{
$this->poll=$poll;
$this->type_poll=$type_poll;
$this->tasks=[];
$this->polls=[];
$this->type_polls=[];
}
public function updatedpoll()
{
$this->tasks= Task::where('process_status', '=', 'new')
->where('id','=', $this->poll)
->orderBy('created_at', 'asc')
->get()
->toArray();
$this->type_polls = Task::where('process_status', '=', 'rich')
->orWhere('poll', '=', $this->poll)
->orderBy('created_at', 'asc')->get();
}
public function render()
{
$this->polls = Task::where('process_status', '=', 'rich')->orderBy('created_at', 'asc')->get();
return view('livewire.search');
}
}
view:
<div>
<div class="mb-8">
<label class="inline-block w-32 font-bold">Filter:</label>
<select name="poll" class="border shadow p-2 bg-white" wire:model='poll'
>
<option value=''>Choose a poll</option>
@foreach($polls as $poll)
<option value={{ $poll->id }}>{{ $poll->poll }}</option>
@endforeach
</select >
<select name="type_poll" class="border shadow p-2 bg-white" wire:model='type_poll'
>
<option value=''>Choose a type_poll</option>
@foreach($type_polls as $type_poll)
<option value={{ $type_poll->id }}>{{ $type_poll->type_poll }}</option>
@endforeach
</select >
<table class="absolute shadow bg-white top-100 z-40 w-full lef-0 rounded max-h-select overflow-y-auto svelte-5uyqqj">
<div class="flex flex-col w-full">
<div class="cursor-pointer w-full border-gray-100 rounded-t border-b hover:bg-teal-100">
@foreach ($tasks as $task)
<tr>
<td>
{{ $task['id'] }}
</td>
<td>
{{ $task['poll'] }}
</td>
<td>
{{ $task['type_poll'] }}
</td>
</tr>
@endforeach
</div>
</div>
</table>
I call the component in the blade view:
<div class="-my-2 py-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
@livewire('search',['poll'=>$event->poll, 'type_poll'=>$event->type_poll])
</div>
give me following error:
Undefined variable: event (View: /Users/L8_test/resources/views/test.blade.php)
well, I don't know what model contains the previous values, so you have to think about where this information comes from then pass it to the view
Please or to participate in this conversation.