Uncategorized

How to return something while you are importing from the Maatwebsite package?

By November 19, 2020 No Comments

When we use code like the following. Notice the variable $createdUser

1
2
3
Excel::import($createdUser = new ClientImport([
   'lenderId' => $request->lender,
]), storage_path($uploadDirectoryWithFilename));

The solution part now:

1
2
3
4
// This will be returned to the caller object
// This does not need to be in the constructor, for my case this was inside the model function which is part of the setup of the Maatwebsite package.

$this->email = $row['email'];

So, we just create a class variable and assigned a value, even if it is not in the constructor, the value is returned.