I get the message Call to a member function beginTransaction() on null when importing data from "Maatwebsite\Excel\Excel" using laravel 8.0 and MongoDB. Export is ok, I've already tried to set transaction handler to 'null' and php artisan config:clear and php artisan config:cache but with no luck. here's my controller
public function store(UserLoadRequest $request)
{
$request->authorize();
$validated = $request->validated();
//dd($request->file('usersList'));
//dd($validated['usersList']->getPathname());
Excel::import(new UsersImport, $request->file('usersList'));
return redirect()->back()->with('success', 'Utenti caricati');
}
and here my import function
class UsersImport implements ToModel, WithHeadingRow
{
public function model(array $row)
{
return new User([
'descrizione' => $row['descrizione'],
'username' => $row['username'],
'password' => Hash::make($row['password']),
'meccanografico' => $row['meccanografico'],
'role_id' => $row['role_id'],
]);
}
}