22
33namespace JustBetter \MagentoCustomerPricesNova \Nova \Actions ;
44
5+ use Illuminate \Support \Carbon ;
56use Illuminate \Support \Collection ;
67use JustBetter \MagentoCustomerPrices \Jobs \Retrieval \RetrieveAllCustomerPricesJob ;
78use Laravel \Nova \Actions \Action ;
89use Laravel \Nova \Actions \ActionResponse ;
910use Laravel \Nova \Fields \ActionFields ;
11+ use Laravel \Nova \Fields \Boolean ;
12+ use Laravel \Nova \Fields \DateTime ;
13+ use Laravel \Nova \Http \Requests \NovaRequest ;
1014
1115class 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