コード例 #1
0
 public function show($id)
 {
     if (Auth::user()->can('read-group')) {
         $data['group'] = Group::find($id);
         $data['title'] = "Group \"" . $data['group']->display_name . "\"";
         $roles = Role::get();
         $roles_in_group = Role::whereHas('groups', function ($q) use($id) {
             $q->where('groups.id', $id);
         })->get();
         $counter = 0;
         foreach ($roles as $role) {
             $is_in_group = false;
             foreach ($roles_in_group as $role_in_group) {
                 if ($role->id == $role_in_group->id) {
                     $is_in_group = true;
                 }
             }
             $data['roles'][$counter] = $role;
             $data['roles'][$counter]['is_in_group'] = $is_in_group;
             $counter++;
         }
         $data['menu_actions'] = [Form::editItem(route('groups.edit', $id), 'Edit This Group', Auth::user()->can('update-group'))];
         return view('groups/show', $data);
     } else {
         return redirect()->back()->withErrors(['Access denied to groups show page']);
     }
 }