Skip to content

Commit b31ce88

Browse files
add isEmptyWhen doc (SpartnerNL#187)
* add isEmptyWhen doc * fix document
1 parent 8bbe425 commit b31ce88

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

3.1/imports/validation.md

+22
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,28 @@ class UsersImport implements ToModel, SkipsEmptyRows, WithHeadingRow, WithValida
303303
}
304304
}
305305
```
306+
## Extend empty rows logic
307+
308+
Along with `SkipsEmptyRows` you can have your own logic to skip rows by having `isEmptyWhen` in the importer
309+
310+
```php
311+
<?php
312+
313+
namespace App\Imports;
314+
315+
use Maatwebsite\Excel\Concerns\Importable;
316+
use Maatwebsite\Excel\Concerns\ToArray;
317+
318+
class UsersImport implements ToArray,
319+
{
320+
use Importable;
321+
322+
public function isEmptyWhen(array $row): bool
323+
{
324+
return $row['name'] === 'John Doe';
325+
}
326+
}
327+
```
306328

307329
### Skipping errors
308330

0 commit comments

Comments
 (0)