To validate data beyond the last row in Laravel Excel, you can use the chunk
method instead of get
to retrieve the data in chunks. This allows you to validate the data row by row until the end of the file is reached.
Here's an example:
Excel::filter('chunk')->load($path)->chunk(200, function ($results) {
// Iterate over each row in the chunk and validate the data
foreach ($results as $row) {
// Validate the row data here
}
});
In this example, the chunk
method retrieves the data in chunks of 200 rows at a time. The foreach
loop then iterates over each row in the chunk and applies the validation logic. This process continues until all rows have been validated, even if there are more rows than can be retrieved in a single chunk.
Asked: 2022-07-04 11:00:00 +0000
Seen: 16 times
Last updated: Nov 06 '22