From 064e41ae403a1298608a116bfc99d72be10806c4 Mon Sep 17 00:00:00 2001 From: Thomas <110615278+tdywd@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:31:16 +0200 Subject: [PATCH 1/3] feat (global) : updated composer.json for compatibility with Laravel 11 --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 275598c..13dcf3c 100644 --- a/composer.json +++ b/composer.json @@ -26,14 +26,14 @@ } ], "require": { - "php": "8.1.*|8.2.*", - "illuminate/contracts": "^9.0|^10.0", - "livewire/livewire": "^2.0" + "php": "8.1.*|8.2.*|8.3.*", + "illuminate/contracts": "^9.0|^10.0|^11.0", + "livewire/livewire": "^2.0|^3.0" }, "require-dev": { "ext-pdo": "*", "brianium/paratest": "^6.4", - "laravel/pint": "^1.1", + "laravel/pint": "*", "nunomaduro/collision": "^6.0", "nunomaduro/larastan": "^2.0", "orchestra/testbench": "^7.0|^8.0", From 1c2a952d107e2b06938efb5e41d101ffe22fb261 Mon Sep 17 00:00:00 2001 From: Thomas <110615278+tdywd@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:36:11 +0200 Subject: [PATCH 2/3] feat (global) : updated file for compatibility with Laravel 11 --- src/RowActions/EditRowAction.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/RowActions/EditRowAction.php b/src/RowActions/EditRowAction.php index 2274776..47e5053 100644 --- a/src/RowActions/EditRowAction.php +++ b/src/RowActions/EditRowAction.php @@ -3,9 +3,8 @@ namespace Okipa\LaravelTable\RowActions; use Illuminate\Database\Eloquent\Model; -use Illuminate\Http\RedirectResponse; use Livewire\Component; -use Livewire\Redirector; +use Livewire\Features\SupportRedirects\Redirector; use Okipa\LaravelTable\Abstracts\AbstractRowAction; class EditRowAction extends AbstractRowAction @@ -45,7 +44,7 @@ protected function defaultFeedbackMessage(Model $model): string|null return null; } - public function action(Model $model, Component $livewire): RedirectResponse|Redirector + public function action(Model $model, Component $livewire): Redirector { return redirect()->to($this->editUrl); } From 85e9dcbcc55583c4bac72a0ed4b5100d0556657b Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 2 Dec 2024 16:05:25 +0400 Subject: [PATCH 3/3] feat (global) : use dispatch instead of emit --- src/HeadActions/RedirectHeadAction.php | 2 +- src/Livewire/Table.php | 18 +++++++++--------- src/RowActions/RedirectRowAction.php | 2 +- src/Table.php | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/HeadActions/RedirectHeadAction.php b/src/HeadActions/RedirectHeadAction.php index 3a98002..9f97a6d 100644 --- a/src/HeadActions/RedirectHeadAction.php +++ b/src/HeadActions/RedirectHeadAction.php @@ -35,7 +35,7 @@ protected function icon(): string public function action(Component $livewire): void { $this->openInNewWindow - ? $livewire->emit('laraveltable:link:open:newtab', $this->url) + ? $livewire->dispatch('laraveltable:link:open:newtab', $this->url) : redirect()->to($this->url); } } diff --git a/src/Livewire/Table.php b/src/Livewire/Table.php index 273be80..e1a5cb0 100644 --- a/src/Livewire/Table.php +++ b/src/Livewire/Table.php @@ -230,7 +230,7 @@ public function reorder(array $newPositions): void foreach ($reorderedPositions->sortBy('position') as $reorderedPosition) { app($modelClass)->find($reorderedPosition['modelKey'])->update([$reorderAttribute => $startOrder++]); } - $this->emit('laraveltable:action:feedback', __('The list has been reordered.')); + $this->dispatch('laraveltable:action:feedback', __('The list has been reordered.')); } public function changeNumberOfRowsPerPage(int $numberOfRowsPerPage): void @@ -268,7 +268,7 @@ public function resetFilters(): void { $this->selectedFilters = []; $this->resetFilters = true; - $this->emitSelf('laraveltable:filters:wire:ignore:cancel'); + $this->dispatch('laraveltable:filters:wire:ignore:cancel'); } public function cancelWireIgnoreOnFilters(): void @@ -295,7 +295,7 @@ public function bulkAction(string $identifier, bool $requiresConfirmation): mixe return null; } if ($requiresConfirmation) { - return $this->emit( + return $this->dispatch( 'laraveltable:action:confirm', 'bulkAction', $identifier, @@ -305,7 +305,7 @@ public function bulkAction(string $identifier, bool $requiresConfirmation): mixe } $feedbackMessage = $bulkActionInstance->getFeedbackMessage(); if ($feedbackMessage) { - $this->emit('laraveltable:action:feedback', $feedbackMessage); + $this->dispatch('laraveltable:action:feedback', $feedbackMessage); } $models = app($bulkActionInstance->modelClass)->findMany($bulkActionInstance->allowedModelKeys); @@ -325,7 +325,7 @@ public function rowAction(string $identifier, string $modelKey, bool $requiresCo } $model = app($rowActionArray['modelClass'])->findOrFail($modelKey); if ($requiresConfirmation) { - return $this->emit( + return $this->dispatch( 'laraveltable:action:confirm', 'rowAction', $identifier, @@ -335,7 +335,7 @@ public function rowAction(string $identifier, string $modelKey, bool $requiresCo } $feedbackMessage = $rowActionInstance->getFeedbackMessage($model); if ($feedbackMessage) { - $this->emit('laraveltable:action:feedback', $feedbackMessage); + $this->dispatch('laraveltable:action:feedback', $feedbackMessage); } return $rowActionInstance->action($model, $this); @@ -353,7 +353,7 @@ public function columnAction(string $identifier, string $modelKey, bool $require } $model = app($columnActionArray['modelClass'])->findOrFail($modelKey); if ($requiresConfirmation) { - return $this->emit( + return $this->dispatch( 'laraveltable:action:confirm', 'columnAction', $identifier, @@ -363,7 +363,7 @@ public function columnAction(string $identifier, string $modelKey, bool $require } $feedbackMessage = $columnActionInstance->getFeedbackMessage($model, $identifier); if ($feedbackMessage) { - $this->emit('laraveltable:action:feedback', $feedbackMessage); + $this->dispatch('laraveltable:action:feedback', $feedbackMessage); } return $columnActionInstance->action($model, $identifier, $this); @@ -375,6 +375,6 @@ public function refresh(array $configParams = [], array $targetedConfigs = []): return; } $this->configParams = [...$this->configParams, ...$configParams]; - $this->emitSelf('$refresh'); + $this->dispatch('$refresh'); } } diff --git a/src/RowActions/RedirectRowAction.php b/src/RowActions/RedirectRowAction.php index 31d75d8..a8510af 100644 --- a/src/RowActions/RedirectRowAction.php +++ b/src/RowActions/RedirectRowAction.php @@ -54,7 +54,7 @@ protected function defaultFeedbackMessage(Model $model): string|null public function action(Model $model, Component $livewire): void { $this->openInNewWindow - ? $livewire->emit('laraveltable:link:open:newtab', $this->url) + ? $livewire->dispatch('laraveltable:link:open:newtab', $this->url) : redirect()->to($this->url); } } diff --git a/src/Table.php b/src/Table.php index a21c7e1..8f2037e 100644 --- a/src/Table.php +++ b/src/Table.php @@ -230,7 +230,7 @@ public function triggerEventsEmissionOnLoad(Livewire\Table $table): void foreach ($this->eventsToEmitOnLoad as $event => $params) { $eventName = is_string($event) ? $event : $params; $eventParams = is_array($params) ? $params : []; - $table->emit($eventName, $eventParams); + $table->dispatch($eventName, $eventParams); } }