Error: Call to a member function beginTransaction() on null

I am getting:

Call to a member function beginTransaction() on null

when importing data from Maatwebsite\Excel\Excel in Laravel and MongoDB. It's working fine on local but when I am running it on the server it's showing me this error.


Solution 1:

I think:

after install run:

php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config

then config file excel.php in config directory