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
Add enhanced import functionality with validation and error handling
- Introduced EnhancedDefaultImport and EnhancedDefaultRelationshipImport classes for improved import capabilities.
- Added methods to stop imports with user-friendly messages for errors, warnings, information, and success.
- Implemented header and custom validation checks in import processes.
- Updated language files for new import status messages.
- Created example solutions demonstrating usage of enhanced imports with validation.
- Added tests to ensure proper functionality of stopping imports and validation checks.
Copy file name to clipboardExpand all lines: README.md
+126-2Lines changed: 126 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -334,10 +334,134 @@ class PostsRelationManager extends RelationManager
334
334
}
335
335
```
336
336
337
-
Everything behaves and can be modified similar to the `ExcelImportAction` class, except the `DefaultRelationshipImport` class is used instead of the `DefaultImport` class. So if you are implementing a custom import class, you will need to extend the `DefaultRelationshipImport` class instead of the `DefaultImport` class.
337
+
### Stopping Imports and Returning Messages
338
338
339
+
**New in v3.1.5+**: You can now stop the import process from within your custom import class and return messages to the frontend. This is useful for:
340
+
341
+
- Header validation to ensure the file format is correct
342
+
- Business logic validation that might require stopping the entire import
343
+
- Custom validation that depends on form data or external conditions
344
+
345
+
#### Using Enhanced Import Classes
346
+
347
+
The package now provides `EnhancedDefaultImport` and `EnhancedDefaultRelationshipImport` classes that include methods to stop imports:
348
+
349
+
```php
350
+
use EightyNine\ExcelImport\EnhancedDefaultImport;
351
+
use Illuminate\Support\Collection;
352
+
353
+
class CustomUserImport extends EnhancedDefaultImport
354
+
{
355
+
protected function beforeCollection(Collection $collection): void
0 commit comments