Skip to content

Commit

Permalink
Improve the readme some more
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp authored Dec 14, 2020
1 parent 29324a8 commit 458fbda
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
## Options
By default, all of your Nova Resources will be available for import. However, there are a number of ways that you can explicitly limit what's available for importing.

`public static $canImportResource = false;`
*Default:* `true`
`public static $canImportResource = false;`
*Default:* `true`
Add this static property to your Resource to prevent it from showing up in the Nova CSV Import tool interface.

`public static function canImportResource($request): bool`
`public static function canImportResource($request): bool`
Define a `canImportResource` method to use more complex logic to decide if this Resource can be shown during import. If defined, this takes precedence over the `$canImportResource` property.

`public static function excludeAttributesFromImport(): array`
*Default:* `[]`
`public static function excludeAttributesFromImport(): array`
*Default:* `[]`
Define a `excludeAttributesFromImport` method that returns an array of attribute names that you want to _exclude_ from being visible in the import tool for this Resource.


Expand All @@ -57,19 +57,24 @@ public static function canImportResource(Request $request)
{
return $request->user()->can("create", self::$model);
}

public static function excludeAttributesFromImport()
{
return ['password'];
}
```

## Importer Class
This package uses [maatwebsite/excel](https://github.com/Maatwebsite/Laravel-Excel) behind the scenes to handle the actual import. You can find more information about how importing [works here](https://docs.laravel-excel.com/3.1/imports/basics.html#importing-basics)
This package uses [maatwebsite/excel](https://github.com/Maatwebsite/Laravel-Excel) behind the scenes to handle the actual import. You can find more information about how importing [works here](https://docs.laravel-excel.com/3.1/imports/basics.html#importing-basics).

You can define your own importer class by providing the relevant class name in your published copy of this package's config file.

Publish the config file
First, publish the config file:
```
php artisan vendor:publish --tag=nova-csv-import
```

Define and register your own importer class
Then, define and register your own importer class:
```
<?php
Expand Down

0 comments on commit 458fbda

Please sign in to comment.