/** * compose permissions variable. */ private function composeAllPermissions() { View::composer(['manage.role.show'], function ($view) { $groups = Permission::distinct()->lists('group'); foreach ($groups as $group) { $permission_groups[$group] = Permission::where('group', $group)->get(); } $view->with(['permission_groups' => $permission_groups]); }); }