From 22ddf4809e70e1b2f8254d212e83a98add225df0 Mon Sep 17 00:00:00 2001 From: Chris Bautista Date: Fri, 11 Oct 2024 13:11:55 +0800 Subject: [PATCH] ExportProcessor updates --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 030f76e..16eef15 100644 --- a/README.md +++ b/README.md @@ -351,14 +351,13 @@ returns the processor class you just created. ```php namespace App\Nova\Exports; -use Coreproc\NovaDataSync\Export\Jobs\ExportProcessor; use Coreproc\NovaDataSync\Export\Nova\Action\ExportNovaAction; -class UserExportAction extends ExportNovaAction +class ProductExportAction extends ExportNovaAction { protected function processor(ActionFields $fields, Collection $models): ExportProcessor { - return new UserExportProcessor(); + return new ProductExportProcessor(); } } ``` @@ -366,6 +365,28 @@ class UserExportAction extends ExportNovaAction If you have additional fields that you want to add to the Export feature, you can define them in the `fields()` method and access them through the `$fields` property. +```php +namespace App\Nova\Exports; + +use Coreproc\NovaDataSync\Export\Nova\Action\ExportNovaAction; + +class ProductExportAction extends ExportNovaAction +{ + protected function processor(ActionFields $fields, Collection $models): ExportProcessor + { + return new ProductExportProcessor($fields->get('start_date'), $fields->get('end_date')); + } + + public function fields(NovaRequest $request): array + { + return [ + Date::make('Start Date')->required(), + Date::make('End Date')->required(), + ]; + } +} +``` + Now, you can add the `ExportNovaAction` to your Nova Resource: ```php