/** * Display a listing of the resource. * * @return Response */ public function index($areaSlug, $categorySlug = null, $postId = null) { $groups = []; $county = $this->user()->county_id; list($area, $category) = $this->repository->areaCategory($areaSlug, $categorySlug, $county); if (!$area || $categorySlug && !$category) { return abort(404); } if ($this->user()->isTrainer()) { $groups = $this->user()->trainerGroups($area, $category); if ($groups->isEmpty()) { return abort(404); } $groupId = Input::get('g'); $group = $groupId ? Group::findOrFail($groupId) : $groups->first(); } else { if (!($group = $this->user()->groupByAreaCategory($area, $category))) { return abort(404); } } if ($postId) { return $this->show($area, $category, $postId); } $posts = $group->posts; return view('area.news', compact('area', 'category', 'posts', 'groups')); }
/** * @return Response */ public function show($groupId) { $group = Group::findOrFail($groupId); if (!$this->user()->can('add_areas') && !in_array($this->user()->id, $group->trainers()->lists('id'))) { return abort(404); } if ($id = Input::get('uid')) { return $this->showUser($group, $id); } return view('admin.members.show', compact('group')); }
/** * @param int $userId * @param int $groupId * @return Response */ public function delete($userId, $groupId) { if ((int) $this->user()->county_id === 26) { exit; } $group = Group::findOrFail($groupId, ['id']); if (!in_array($this->userId, $group->trainers()->lists('id'))) { return abort(404); } $user = User::findOrFail($userId, ['id']); $user->groups()->detach($groupId); if (Request::wantsJson()) { return json(1); } return back(); }
/** * Remove the specified resource from storage. * * @param int $_ * @param int $id * @return Response */ public function destroy($_, $id) { $group = Group::findOrFail($id); $group->delete(); return json(1); //return Redirect::route('admin.areas.edit', $group->area->id)->withDelete(true); }
public function destroy($_, $groupId, $id) { $group = Group::findOrFail($groupId); $group->users()->detach($id); return json(1); }