Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unable to resolve NULL driver for [Maatwebsite\Excel\Transactions\TransactionManager] #2384

Closed
gcjbr opened this issue Oct 2, 2019 · 7 comments
Labels

Comments

@gcjbr
Copy link

gcjbr commented Oct 2, 2019

Prerequisites

Versions

  • PHP version: PHP 7.3.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 2 2019 12:54:04) ( NTS )
  • Laravel version: v6.0.4
  • Package version: 3.1.17

Description

When trying to import a XLS I get the following error

Unable to resolve NULL driver for [Maatwebsite\Excel\Transactions\TransactionManager].

Steps to Reproduce

The code to import is:

Excel::import(new ProdutosImport, $file)

And the actual import is

<?php

namespace App\Imports;

use App\Produto;
use Maatwebsite\Excel\Concerns\OnEachRow;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class ProdutosImport implements OnEachRow, WithHeadingRow
{
    /**
     * @param array $row
     *
     * @return \Illuminate\Database\Eloquent\Model|null
     */
    public function onRow($row)
    {
        $row = $row->toArray();
        if ($row['nmero_do_pedido'] !== null && $row['sku'] !== null) {
            $produto = Produto::firstOrNew(['id_venda' => $row['nmero_do_pedido'], 'sku' => $row['sku'], 'sequeencia' => null]);
            $produto->id_venda = $row['nmero_do_pedido'];
            $produto->sequeencia = null;
            $produto->sku = $row['sku'];
            $produto->data_pagamento = $row['data_de_pagamento'];
            $produto->estado_pagamento = $row['status_do_pagamento'];
            $produto->titulo_produto = $row['nome_do_produto'];
            $produto->sub_total = $row['valor_do_produto'];
            $produto->descuento_compra = 0;
            $produto->total_venda = $row['valor_do_produto'];

            $produto->save();
        }
    }
}

Expected behavior:

Import the file.

Actual behavior:

Errors out with
Unable to resolve NULL driver for [Maatwebsite\Excel\Transactions\TransactionManager].

Additional Information

Even though I'm not using Mongo I tried disabling transactions as suggested at #1998, but it changed nothing.

@gcjbr gcjbr added the bug label Oct 2, 2019
@patrickbrouwers
Copy link
Member

Have you tried my answer in #1998 (comment) ? Sounds like your are using the wrong config value.

@gcjbr
Copy link
Author

gcjbr commented Oct 3, 2019

Have you tried my answer in #1998 (comment) ? Sounds like your are using the wrong config value.

I tried both. Also tried the default configs.

Shouldn't the default configs work, since I'm using MySQL, anyways?

@gcjbr
Copy link
Author

gcjbr commented Oct 3, 2019

BTW, @patrickbrouwers , I get the same exact message 'Unable to resolve NULL driver' whether I have 'db' or 'null' as a value for 'handler'

@gcjbr
Copy link
Author

gcjbr commented Oct 3, 2019

Ok, I did some investigation and it's not a bug.

Laravel cache was on the way of the package reading the new published vendor config.

A simple php artisan config:clear did it.

@Moustafa22
Copy link

I faced this issue, my problem was that I'm using the library without adding the config file excel.php.

so I traced it by clearing the cache (and it worked), then i added the config file then cached my config again.

I hope this helps.

@Mahfujur51
Copy link

Just run php artisan config:clear or php artisan config:cache.

@saiful-anwar
Copy link

saiful-anwar commented Oct 7, 2021

Have you tried my answer in #1998 (comment) ? Sounds like your are using the wrong config value.

Thank you for saving my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants