use App\Models\User; $user = User::with('roles')->first(); return $user->toArray();
$users = App\User::all(); $users = $users->toArray();
function objectToArray(&$object) { return @json_decode(json_encode($object), true); }