From 458fbda3f9e3f39258efaf848aa538919b896b06 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 14 Dec 2020 19:43:50 +0000 Subject: [PATCH] Improve the readme some more --- README.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7f5776b..4297cd8 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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: ```