예제 #1
0
 public function removeModerator()
 {
     $moderator = GroupModerator::findOrFail(request('id'));
     $group = $moderator->group;
     if (!user()->isAdmin($moderator->group)) {
         abort(403, 'Access denied');
     }
     if ($moderator->user_id == $group->creator_id && Auth::id() != $group->creator_id) {
         return response()->json(['status' => 'error']);
     }
     $moderator->delete();
     // Log this action
     $action = new ModeratorAction();
     $action->type = ModeratorAction::TYPE_MODERATOR_REMOVED;
     $action->is_admin = $moderator->type == 'admin' ? true : false;
     $action->moderator()->associate(user());
     $action->target()->associate($moderator);
     $action->group()->associate($group);
     $action->save();
     \Cache::tags(['user.moderated-groups', 'u.' . $moderator->user_id])->flush();
     return response()->json(['status' => 'ok']);
 }
예제 #2
0
 public function removeModerator()
 {
     $moderator = GroupModerator::findOrFail(Input::get('id'));
     $group = $moderator->group;
     if (!Auth::user()->isAdmin($moderator->group)) {
         App::abort(403, 'Access denied');
     }
     if ($moderator->user_id == $group->creator_id && Auth::id() != $group->creator_id) {
         return Response::json(['status' => 'error']);
     }
     $moderator->delete();
     // Log this action
     $action = new ModeratorAction();
     $action->type = ModeratorAction::TYPE_MODERATOR_REMOVED;
     $action->is_admin = $moderator->type == 'admin' ? true : false;
     $action->moderator()->associate(Auth::user());
     $action->target()->associate($moderator);
     $action->group()->associate($group);
     $action->save();
     return Response::json(['status' => 'ok']);
 }