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