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