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