SolvedLaravel Excel [BUG] Error import: object beginTransaction


  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.


  • PHP version: 7.2
  • Laravel version: 5.7.17
  • Package version: 3.1.3


I have created the import object class and specified the Concerns of ToCollection. Upon performing Excel::import, I receive an error shown in Actual Behavior below.

Steps to Reproduce

Do not use a transactional database. We use MongoDB.

Aside from that, Model importing was not specified and the package should not be doing any database preparation, that should be handled through events by the developer.

Expected behavior:

dd of the collection rows.

Actual behavior:

1) Tests\Unit\Services\Websites\WebsiteCredentialsImportServiceTest::testImportTabDelimited
Error: Call to a member function beginTransaction() on null


Additional Information


namespace App\Imports\Websites;

use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;

 * Class WebsiteCredentialsImport
 * @package App\Imports\Websites
class WebsiteCredentialsImport implements ToCollection
    public function collection(Collection $rows)
        dd(['COLLECTION' => $rows]);
        $collection = Excel::import(
            new WebsiteCredentialsImport,
14 Answers

✔️Accepted Answer

Maybe you guys are having the same issue I did at #2384

Maybe my solution would work for you, try a:

php artisan config:clear

Sometimes, specially when updating a package, Laravel won't clean the cache and your package won't find the config files. Thus, the driver will be always NULL and fail.

Other Answers:

Next version will have a setting to disable Laravel-DB transactions + a way to add custom transaction handlers

You are probably typing something wrong in your config then. NULL doesn't sound like a valid driver. 'null' (note that it is a string) is.

More Issues: