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