i want to export data from my json to csv file but i get this error Cannot use object of type stdClass as array
i want to know please how i can use it as array
public function exportUsers()
{
$users = ServicePoint::all()->where("nature", "SP")->toArray();
$users = ServicePoint::all()->where('statut','<>', 2);
$arrayCsv = [];
foreach ($users as $key => $line){
$arrayCsv[$key][] = $line['name'];
$arrayCsv[$key][] = $line['lastname'];
$arrayCsv[$key][] = $line['email'];
}
anything can help please