Interact with Event in custom livewire component with filament table
class AvailableRooms extends Component implements HasTable, HasForms
{
use InteractsWithTable;
use InteractsWithForms;
public $availableRoomID = [];
#[On('availableRoom')]
public function index($available_room_id){
$this->availableRoomID = $available_room_id;
}
function table(Table $table): Table
{
return $table
->query(Room::whereIn('id', $this->availableRoomID))
->columns([
TextColumn::make('room_name'),
TextColumn::make('room_type'),
]);
}
public function render()
{
return view('livewire.available-rooms');
}
}
When I receive event from available room, i want to store it to $availableRoomID variable and use it to query table. However it run table function run first and then run funtion for event. So variable is wrong for table query. How can I make it work for dynamic query? Or Can I run event function first? Thanks for Reading.0 Replies