repository = $activity_community; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Annie\Activity\Repositories\Criteria\ActivityCommunityResourceCriteria::class); } /** * Display a list of activity_community. * * @return Response */ public function index(ActivityCommunityRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Annie\Activity\Repositories\Presenter\ActivityCommunityPresenter::class) ->$function(); } $activity_communities = $this->repository->paginate(); return $this->response->setMetaTitle(trans('activity::activity_community.names')) ->view('activity::activity_community.index', true) ->data(compact('activity_communities', 'view')) ->output(); } /** * Display activity_community. * * @param Request $request * @param Model $activity_community * * @return Response */ public function show(ActivityCommunityRequest $request, ActivityCommunity $activity_community) { if ($activity_community->exists) { $view = 'activity::activity_community.show'; } else { $view = 'activity::activity_community.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('activity::activity_community.name')) ->data(compact('activity_community')) ->view($view, true) ->output(); } /** * Show the form for creating a new activity_community. * * @param Request $request * * @return Response */ public function create(ActivityCommunityRequest $request) { $activity_community = $this->repository->newInstance([]); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('activity::activity_community.name')) ->view('activity::activity_community.create', true) ->data(compact('activity_community')) ->output(); } /** * Create new activity_community. * * @param Request $request * * @return Response */ public function store(ActivityCommunityRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $activity_community = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('activity::activity_community.name')])) ->code(204) ->status('success') ->url(guard_url('activity/activity_community/' . $activity_community->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/activity/activity_community')) ->redirect(); } } /** * Show activity_community for editing. * * @param Request $request * @param Model $activity_community * * @return Response */ public function edit(ActivityCommunityRequest $request, ActivityCommunity $activity_community) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('activity::activity_community.name')) ->view('activity::activity_community.edit', true) ->data(compact('activity_community')) ->output(); } /** * Update the activity_community. * * @param Request $request * @param Model $activity_community * * @return Response */ public function update(ActivityCommunityRequest $request, ActivityCommunity $activity_community) { try { $attributes = $request->all(); $activity_community->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('activity::activity_community.name')])) ->code(204) ->status('success') ->url(guard_url('activity/activity_community/' . $activity_community->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('activity/activity_community/' . $activity_community->getRouteKey())) ->redirect(); } } /** * Remove the activity_community. * * @param Model $activity_community * * @return Response */ public function destroy(ActivityCommunityRequest $request, ActivityCommunity $activity_community) { try { $activity_community->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('activity::activity_community.name')])) ->code(202) ->status('success') ->url(guard_url('activity/activity_community/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('activity/activity_community/' . $activity_community->getRouteKey())) ->redirect(); } } /** * Remove multiple activity_community. * * @param Model $activity_community * * @return Response */ public function delete(ActivityCommunityRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('activity::activity_community.name')])) ->status("success") ->code(202) ->url(guard_url('activity/activity_community')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/activity/activity_community')) ->redirect(); } } /** * Restore deleted activity_communities. * * @param Model $activity_community * * @return Response */ public function restore(ActivityCommunityRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('activity::activity_community.name')])) ->status("success") ->code(202) ->url(guard_url('/activity/activity_community')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/activity/activity_community/')) ->redirect(); } } }