Convert laravel object to array

The Solution to Convert laravel object to array is

UPDATE since version 5.4 of Laravel it is no longer possible.

You can change your db config, like @Varun suggested, or if you want to do it just in this very case, then:


// then
DB::table(..)->get(); // array of arrays instead of objects

// of course to revert the fetch mode you need to set it again

For New Laravel above 5.4 (Ver > 5.4) see fetch mode section

Event::listen(StatementPrepared::class, function ($event) {

~ Answered on 2014-10-03 07:25:44

Most Viewed Questions: