Skip to content

Commit b455d4c

Browse files
committed
Add support for defer
1 parent d16c5ef commit b455d4c

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^8.3",
2020
"bolechen/nova-activitylog": "^0.5.0",
21-
"justbetter/laravel-magento-customer-prices": "^3.0",
21+
"justbetter/laravel-magento-customer-prices": "^3.2.4",
2222
"laravel/framework": "^11.0|^12.0",
2323
"laravel/nova": "^5.0"
2424
},

src/Nova/Actions/RetrieveAllCustomerPrices.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
namespace JustBetter\MagentoCustomerPricesNova\Nova\Actions;
44

5+
use Illuminate\Support\Carbon;
56
use Illuminate\Support\Collection;
67
use JustBetter\MagentoCustomerPrices\Jobs\Retrieval\RetrieveAllCustomerPricesJob;
78
use Laravel\Nova\Actions\Action;
89
use Laravel\Nova\Actions\ActionResponse;
910
use Laravel\Nova\Fields\ActionFields;
11+
use Laravel\Nova\Fields\Boolean;
12+
use Laravel\Nova\Fields\DateTime;
13+
use Laravel\Nova\Http\Requests\NovaRequest;
1014

1115
class RetrieveAllCustomerPrices extends Action
1216
{
@@ -21,8 +25,30 @@ public function __construct()
2125

2226
public function handle(ActionFields $fields, Collection $models): ActionResponse
2327
{
24-
RetrieveAllCustomerPricesJob::dispatch();
28+
/** @var ?string $from */
29+
$from = $fields->get('from');
30+
31+
if ($from !== null) {
32+
$carbon = Carbon::parse($from);
33+
}
34+
35+
/** @var bool $defer */
36+
$defer = $fields->get('defer');
37+
38+
RetrieveAllCustomerPricesJob::dispatch($carbon ?? null, $defer);
2539

2640
return ActionResponse::message(__('Retrieving...'));
2741
}
42+
43+
public function fields(NovaRequest $request): array
44+
{
45+
return [
46+
DateTime::make(__('From'), 'from')
47+
->help(__('Optional, retrieve updated prices from this date')),
48+
49+
Boolean::make(__('Defer'), 'defer')
50+
->default(true)
51+
->help(__('When enabled, the prices will be marked for retrieval. Otherwise, all prices will be retrieved immediately.')),
52+
];
53+
}
2854
}

0 commit comments

Comments
 (0)