我正在使用Maatwebsite / Excel软件包导出.csv文件。我的代码在localhost上运行良好,但是当我尝试在实际服务器上运行它时,它无法正常工作并显示
local.INFO:preg_match()期望参数2为字符串,给定数组 在线号62
在本地主机上,当我导出生成的报告时,它将存储在公共/报告中,并且电子邮件也将发送给用户。但是当我在服务器上运行代码时,它给出了错误
它是控制器功能:
try {
$report = 'Appointment_' . Carbon::now()->toDateTimeString() . '_Report.csv';
$report_path = 'reports/Appointment_' . Carbon::now()->toDateTimeString() . '_Report.csv';
// Log::info(var_dump($data));
$created = Excel::store($data, $report, 'reports');
$user_id = $request->session()->get('user_id');
app('App\Http\Controllers\API\AppointmentController')->sendDocument($report_path, config('constants.DOCUMENT_TYPE.REP'), $user_id);
if($created) {
echo json_encode(array('type' => 'success', 'message' => 'Report Exported successfully'));
}
这是Exports中的收集代码:
public function collection()
{
$data = Session::get('report_query');
// Log::info($data);
$d = DB::select($data);
return collect($d);
}
public function headings(): array
{
$field = Session::get('fields');
foreach ($field as $f) {
$arr[] = config("constants.REPORTS_FIELDS." . str_replace('.', '_', $f));
}
return $arr;
// return array_keys($this->collection()->toArray()[0]);
}