diff --git a/app/Http/Livewire/BitcoinEvent/BitcoinEventTable.php b/app/Http/Livewire/BitcoinEvent/BitcoinEventTable.php index fe107717..72e11b1e 100644 --- a/app/Http/Livewire/BitcoinEvent/BitcoinEventTable.php +++ b/app/Http/Livewire/BitcoinEvent/BitcoinEventTable.php @@ -2,6 +2,7 @@ namespace App\Http\Livewire\BitcoinEvent; +use App\Models\BitcoinEvent; use App\Models\Country; use Livewire\Component; @@ -10,6 +11,27 @@ class BitcoinEventTable extends Component public Country $country; public function render() { - return view('livewire.bitcoin-event.bitcoin-event-table'); + return view('livewire.bitcoin-event.bitcoin-event-table', [ + 'events' => BitcoinEvent::query() + ->get() + ->map(fn($event) => [ + 'id' => $event->id, + 'startDate' => $event->from, + 'endDate' => $event->to, + 'location' => $event->title, + 'description' => $event->description, + ]), + ]); + } + + public function popover($content, $ids) + { + return to_route('bitcoinEvent.table.bitcoinEvent', [ + 'country' => $this->country->code, 'table' => [ + 'filters' => [ + 'byid' => $ids, + ] + ] + ]); } } diff --git a/app/Http/Livewire/Tables/BitcoinEventTable.php b/app/Http/Livewire/Tables/BitcoinEventTable.php index a38b898e..a07e7221 100644 --- a/app/Http/Livewire/Tables/BitcoinEventTable.php +++ b/app/Http/Livewire/Tables/BitcoinEventTable.php @@ -6,6 +6,7 @@ use App\Models\BitcoinEvent; use Illuminate\Database\Eloquent\Builder; use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\Views\Column; +use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter; class BitcoinEventTable extends DataTableComponent { @@ -34,6 +35,17 @@ class BitcoinEventTable extends DataTableComponent ->setPerPage(10); } + public function filters(): array + { + return [ + TextFilter::make('Event by ID', 'byid') + ->hiddenFromMenus() + ->filter(function (Builder $builder, string $value) { + $builder->whereIn('bitcoin_events.id', str($value)->explode(',')); + }), + ]; + } + public function columns(): array { return [ diff --git a/resources/views/livewire/bitcoin-event/bitcoin-event-table.blade.php b/resources/views/livewire/bitcoin-event/bitcoin-event-table.blade.php index 43232653..19c2e1ea 100644 --- a/resources/views/livewire/bitcoin-event/bitcoin-event-table.blade.php +++ b/resources/views/livewire/bitcoin-event/bitcoin-event-table.blade.php @@ -4,6 +4,72 @@ {{-- MAIN --}}
+
+ + + + + + + +
+
+
+
+