I have the following query:
$data = DB::table('users')
->select(['id', 'firstName AS inputFirstName', 'lastName AS inputLastName', 'email AS inputEmail'])
->where('id', '=',$id )
->first();
It returns object but I need array and I convert it in this way:
$array_data = json_decode(json_encode((array) $data), true);
But I'm not sure this is the right way to do it! I'm using Laravel 4.2 and I need to make this select query with aliases, that's why I'm not using Eloquent but this raw query.
Is there better way to make this select query to return array? Thanks!
</div>