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