Level 8
Well can you show MagnetbumiController.php line 155 where you using Carbon.
Code you provided not using carbon
I am trying to import excel file, there is a column with "date" information, when I insert in to database it return like this that contains date field return "Cannot use object of type Carbon\Carbon as array"",
here is my controller codes:
public function importExcel(Request $request)
{
//$this->validate($request, [ 'excel' => 'required|mimes:xls,xlsx']);
if($request->hasFile('excel')){
$path = $request->file('excel')->getRealPath();
$data = Excel::load($path, function($reader) {})->get();
if(!empty($data) && $data->count()){
foreach ($data->toArray() as $key => $rows) {
if(!empty($rows)){
foreach ($rows as $row) {
$insert[] = [
'tanggal' => $row['tanggal'],
'waktu' => $row['waktu'],
'lintang' => $row['lintang'],
'bujur' => $row['bujur'],
'magnitudo' => $row['magnitudo'],
'kedalaman' => $row['kedalaman'],
'lokasi' => $row['lokasi'],
'terasa' => $row['terasa'],
'dirasakan' => $row['dirasakan'],
'pga_z' => $row['pga_z'],
'pga_ns' => $row['pga_ns'],
'pga_ew' => $row['pga_ew'],
'sumber' => $row['sumber']
];
}
}
}
if(!empty($insert)){
Gempabumi::insert($insert);
\Alert::success('Data berhasil ditambahkan')->flash();
return redirect('admin/pengamatan/gempabumi');
}
}
}
//\Alert::error('Ada yang salah dengan data anda, tolong perbaiki')->flash();
return back()->with('error', 'Ada yang salah, silahkan cek data anda');
}
and here is the error
[2017-02-02 22:14:27] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Cannot use object of type Carbon\Carbon as array in /Users/jambari/Desktop/code/office/app/Http/Controllers/MagnetbumiController.php:155
How to fix this ? please help me !
Please or to participate in this conversation.