如何从控制器而不是从数据库导出查询以及从控制器导出结果数据?
例如:
switch ($tipe) {
case 'car':
$totaldata2 = \DB::select(\DB::raw("
SELECT $flag as label,
COUNT(tr.id) as data
FROM driver tr
LEFT JOIN vw_driver vw ON vw.id = tr.id
WHERE tr.service= 'C'
$where
GROUP BY $flag
ORDER BY $flag asc
"));
我希望从上面的结果数据中导出的CSV是
period_count,"status_label","status_data","service_label","service_data"