gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 11:16:25 25 4
gpt4 key购买 nike

我正在尝试将数据从数据库下载到 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com