Refresh table contents with Action
Hi guys,
I've created a form with the input fields (start_date & end_date), a button with the "findAssets" Action and a livewire component that is the table for the results, but I don't know how can refresh table when clicking Search button and running query with parameters.
Page Action Code:
public function findAssets() {
$args = $this->form->getState();
$start_date = Carbon::parse($args['start_date']);
$end_date = Carbon::parse($args['end_date']);
$results = Asset::findAvailableAssets($start_date, $end_date);
dd($results);
}
View Code:
<x-filament-panels::page>
<div class="container w-1/2">
{{ $this->form }}
<div class="my-4">
<x-filament::button wire:click="findAssets" color="info">
Search
</x-filament::button>
</div>
</div>
@livewire('custom-table')
</x-filament-panels::page>
Is there a way to send $results data to custom-table component or I should change approach?1 Reply
Ok, I've found what I'm missing. I should use the Action on the entire form, it was an error on Livewire component view. I'll leave here for future reference:
<x-filament-panels::page>
<div class="container w-1/2">
<form wire:submit="findAssets">
{{ $this->form }}
<div class="my-4">
<x-filament::button type="submit" color="info">
Search
</x-filament::button>
</div>
</form>
</div>
<div class="container w-1/2">
RESULTS
@foreach ($results as $result)
<li>{{ $result['ccid'] }}</li>
@endforeach
</div>
<x-filament-actions::modals />
</x-filament-panels::page>