Monday, April 3, 2017

Get an error: Object of class stdClass could not be converted to string when export to excel using maatwebsite

I want to show three tables, three tables are later to be exported, but I am having a problem here, please help me resolve my problem. Thank you.

public function downloadExcel($type)
{
     $data = DB::table('tb_siswa')
            ->join('tb_ayah', 'tb_siswa.id', '=', 'tb_ayah.id_siswa')
            ->join('tb_ibu', 'tb_siswa.id', '=', 'tb_ibu.id_siswa')
            ->select('tb_siswa.nm_lengkap', 'tb_ayah.nm_ayah', 'tb_ibu.nm_ibu')
            ->get();   
    return Excel::create('Data siswa', function($excel) use ($data) {
        $excel->sheet('datasiswa', function($sheet) use ($data)
        {
            $sheet->fromArray($data);
        });
    })->download($type);
}



via imamahmad ashari

Advertisement