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