You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,54 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
34
34
}
35
35
```
36
36
37
+
## Options
38
+
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.
39
+
40
+
`public static $canImportResource = false;`
41
+
*Default:*`true`
42
+
Add this static property to your Resource to prevent it from showing up in the Nova CSV Import tool interface.
43
+
44
+
`public static function canImportResource($request): bool`
45
+
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.
46
+
47
+
`public static function excludeAttributesFromImport(): array`
48
+
*Default:*`[]`
49
+
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.
50
+
51
+
52
+
### Example
53
+
54
+
```php
55
+
// App\Nova\User
56
+
public static function canImportResource(Request $request)
public static function excludeAttributesFromImport()
62
+
{
63
+
return ['password'];
64
+
}
65
+
```
66
+
67
+
## Importer Class
68
+
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).
69
+
70
+
You can define your own importer class by providing the relevant class name in your published copy of this package's config file.
71
+
72
+
First, publish the config file:
73
+
```
74
+
php artisan vendor:publish --tag=nova-csv-import
75
+
```
76
+
77
+
Then, define and register your own importer class:
78
+
```
79
+
<?php
80
+
81
+
return [
82
+
'importer' => App\Utilities\Importer::class,
83
+
];
84
+
```
37
85
## Testing
38
86
39
87
We need tests! Can you help? Please consider contributing.
0 commit comments