Skip to content

Commit

Permalink
ExportProcessor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbjr committed Oct 11, 2024
1 parent 1a61adb commit 22ddf48
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,21 +351,42 @@ 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();
}
}
```

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
Expand Down

0 comments on commit 22ddf48

Please sign in to comment.