laravel - 无法解析 [Maatwebsite\Excel\Transactions\TransactionManager] 的 NULL 驱动程序

标签 laravel

我正在尝试将数据从数据库下载到 excel 文件。我也从 Composer 导入了 Maatwebsite\Excel。
我的 Controller 中的代码是:

function excel()
    {
$month = date('m');
DB::statement("CREATE OR REPLACE VIEW monthly_cost AS
select  user_name,  id, phone, sum(cost) as cost from (
        select users.name as user_name, users.roll as id,users.phone as phone, BC.individual_cost as cost
        from breakfast_orders BO, breakfast_costs BC,users
        WHERE (BO.date=BC.date) and (BO.user_id=users.id)and MONTH(BO.date)='$month'
        UNION ALL
        select users.name as user_name, users.roll as id,users.phone as phone, LC.individual_cost as cost
        from lunch_orders LO, lunch_costs LC,users
        WHERE (LO.date=LC.date) and (LO.user_id=users.id) and MONTH(LO.date)='$month'
        UNION ALL
        select users.name as user_name, users.roll as id,users.phone as phone, DC.individual_cost as cost
        from dinner_orders ddO, dinner_costs DC,users
        WHERE (ddO.date=DC.date) and (ddO.user_id=users.id) and MONTH(ddO.date)='$month'
            ) x group by id,user_name,phone");

     $customer_data=DB::table('monthly_cost')->get()->toArray();
     $customer_array[] = array('Name', 'ID', 'Phone', 'Cost', 'Month');
     foreach($customer_data as $customer)
     {
      $customer_array[] = array(
       'Name'  => $customer->user_name,
       'ID'   => $customer->id,
       'Phone'    => $customer->phone,
       'Cost'  => $customer->cost,
       'Month'   => $month
      );
     }
     Excel::create('Customer Data', function($excel) use ($customer_array){
      $excel->setTitle('Customer Data');
      $excel->sheet('Customer Data', function($sheet) use ($customer_array){
       $sheet->fromArray($customer_array, null, 'A1', false, false);
      });
     })->download('xlsx');
    }

我现在该怎么办?

最佳答案

就跑 php artisan config:clearphp artisan config:cache .

关于laravel - 无法解析 [Maatwebsite\Excel\Transactions\TransactionManager] 的 NULL 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62473158/

相关文章:

php - 在 Laravel 8 中如何制作带有参数的 Blade 指令?

php - 使用 cPanel 和 Laravel 将电子邮件传输到程序

php - 如何检查给定日期是否晚于 3 天?

php - Laravel 5.0 [PDOException] SQLSTATE [HY000] : General error: 1215 Cannot add foreign key constraint

mysql - 将新列添加到现有表并将其显示到 View Blade 中(LARAVEL,mysql)

php - Laravel 4 DB :raw() is unavailable when running outside of framework

php - 具有可变数量的 where 子句的 Laravel 5 查询

php - 修正了一个我认为应该禁用整个路由资源但只禁用带有通配符的 URI 的拼写错误

date - 使用 Eloquent,我如何过滤我的模型查询以仅包含今天创建的项目?

php - 目标 [League\OAuth2\Server\Repositories\ClientRepositoryInterface] 在构建 [League\OAuth2\Server\AuthorizationServer] 时不可实例化