I'm using Maatwebsite/Laravel-Excel for importing some data into my laravel app.
I'm looping trought the rows of the excel, validating the data and then save it, but if I got a validation error I want to return the $error variable from outside the Excel::load() function. Is it possible?
public function import()
{
Excel::load(Input::file('excelFile'), function ($reader) {
foreach ($reader->toArray() as $row) {
if($everythingOK){
//do stuff
} else {
$errors[] = 'error';
}
}
});
return $errors;
}