śledzę this documentationobiektu klasy stdClass nie może być zamieniony na ciąg - laravel
wdrożyć Eksport do Excela w moim laravel 4 projektu.
jestem tak stara, aby wygenerować plik Excel z tablicy tak:
//$results is taken with db query
$data = array();
foreach ($results as $result) {
$result->filed1 = 'some modification';
$result->filed2 = 'some modification2';
$data[] = $result;
}
Excel::create('Filename', function($excel) use($data) {
$excel->sheet('Sheetname', function($sheet) use($data) {
$sheet->fromArray($data);
});
})->export('xls');
Ale to podnosi wyjątek:
Object of class stdClass could not be converted to string
Co robię źle?
UPDATE:
Tried to:
$data = get_object_vars($data);
co skutkuje:
get_object_vars() expects parameter 1 to be object, array given
następująco:
$data = (array)$data;
Wyniki w początkowym błędem.
Myślę, że coś przeoczyłeś w swojej konfiguracji. Sprawdź dwukrotnie plik 'app/config.php' dla dostawcy usług i aliasów. –