Skip to content

Commit

Permalink
Use Nova's action response
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentBean committed Jun 15, 2023
1 parent f73123c commit 6615332
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Nova/Actions/ResetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Collection;
use JustBetter\AkeneoProducts\Models\Product;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse;
use Laravel\Nova\Fields\ActionFields;

class ResetAction extends Action
Expand All @@ -22,7 +23,7 @@ class ResetAction extends Action

public $confirmButtonText = 'Reset';

public function handle(ActionFields $fields, Collection $models): array
public function handle(ActionFields $fields, Collection $models): ActionResponse
{
$models->each(function (Product $product): void {
$product->synchronize = true;
Expand All @@ -33,6 +34,6 @@ public function handle(ActionFields $fields, Collection $models): array
$product->save();
});

return Action::message(__('Reset!'));
return ActionResponse::message(__('Reset!'));
}
}
5 changes: 3 additions & 2 deletions src/Nova/Actions/RetrieveAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Collection;
use JustBetter\AkeneoProducts\Models\Product;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse;
use Laravel\Nova\Fields\ActionFields;

class RetrieveAction extends Action
Expand All @@ -22,13 +23,13 @@ class RetrieveAction extends Action

public $confirmButtonText = 'Retrieve';

public function handle(ActionFields $fields, Collection $models): array
public function handle(ActionFields $fields, Collection $models): ActionResponse
{
$models->each(function (Product $product): void {
$product->retrieve = true;
$product->save();
});

return Action::message(__('Marked!'));
return ActionResponse::message(__('Marked!'));
}
}
5 changes: 3 additions & 2 deletions src/Nova/Actions/UpdateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Support\Collection;
use JustBetter\AkeneoProducts\Models\Product;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse;
use Laravel\Nova\Fields\ActionFields;

class UpdateAction extends Action
Expand All @@ -22,14 +23,14 @@ class UpdateAction extends Action

public $confirmButtonText = 'Update';

public function handle(ActionFields $fields, Collection $models): array
public function handle(ActionFields $fields, Collection $models): ActionResponse
{
$models->each(function (Product $product): void {
$product->retrieve = false;
$product->update = true;
$product->save();
});

return Action::message(__('Marked!'));
return ActionResponse::message(__('Marked!'));
}
}

0 comments on commit 6615332

Please sign in to comment.