I've got an import class which has multiple sheets; I'm performing validation within the array() function manually. If there are any validation issues with the first sheet, it just throws the ValidationException and so I can only see issues with the first sheet. Is there anything I can do to continue onto the next sheet even if the first fails?
public function collection(Collection $rows)
{
try {
Validator::make($rows->toArray(), [
'*.0' => 'required',
])->validate();
} catch(ValidationException $e)
{
// store validation errors somewhere and get them at the end of the validation via a getter
}
foreach ($rows as $row) {
User::create([
'name' => $row[0],
]);
}
}
(extended version of https://docs.laravel-excel.com/3.1/imports/validation.html#row-validation-without-tomodel; handle the try-catch yourself)
Good idea, will give that a go.
Most helpful comment
(extended version of https://docs.laravel-excel.com/3.1/imports/validation.html#row-validation-without-tomodel; handle the try-catch yourself)