From 23750c3c1ef2b79e4e8092b55170ca95d08f24d0 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Mon, 26 Aug 2024 08:12:27 +0100 Subject: [PATCH] Update 08-import.md --- .../docs/07-prebuilt-actions/08-import.md | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/actions/docs/07-prebuilt-actions/08-import.md b/packages/actions/docs/07-prebuilt-actions/08-import.md index ef1dcb6159..b6dfed7e65 100644 --- a/packages/actions/docs/07-prebuilt-actions/08-import.md +++ b/packages/actions/docs/07-prebuilt-actions/08-import.md @@ -159,20 +159,6 @@ ImportColumn::make('sku') Any rows that do not pass validation will not be imported. Instead, they will be compiled into a new CSV of "failed rows", which the user can download after the import has finished. The user will be shown a list of validation errors for each row that failed. -### Marking columns as sensitive -You may want to exclude certain columns from the failed import data to avoid storing sensitive or encrypted information in plain text. To achieve this, you can use the `sensitive()` method on the `ImportColumn` class: - -```php -use Filament\Actions\Imports\ImportColumn; - -ImportColumn::make('ssn') - ->label('Social Security Number') - ->sensitive() - ->rules(['required', 'digits:9']) -``` - -When a column is marked as sensitive, its data will be excluded from the JSON data stored for any failed import rows. This helps to ensure that sensitive information is not stored in a vulnerable manner. - ### Casting state Before [validation](#validating-csv-data), data from the CSV can be cast. This is useful for converting strings into the correct data type, otherwise validation may fail. For example, if you have a `price` column in your CSV, you may want to cast it to a float: @@ -350,6 +336,19 @@ ImportColumn::make('customer_ratings') ->nestedRecursiveRules(['integer', 'min:1', 'max:5']) ``` +### Marking column data as sensitive + +When import rows fail validation, they are logged to the database, ready for export when the import completes. You may want to exclude certain columns from this logging to avoid storing sensitive data in plain text. To achieve this, you can use the `sensitive()` method on the `ImportColumn` to prevent its data from being logged: + +```php +use Filament\Actions\Imports\ImportColumn; + +ImportColumn::make('ssn') + ->label('Social security number') + ->sensitive() + ->rules(['required', 'digits:9']) +``` + ### Customizing how a column is filled into a record If you want to customize how column state is filled into a record, you can pass a function to the `fillRecordUsing()` method: @@ -864,4 +863,4 @@ public function view(User $user, Import $import): bool { return $import->user()->is($user); } -``` \ No newline at end of file +```