form = JobProfileForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('beo.career.modules'), 'career', guard_url('career')); } /** * Display a list of job_profile. * * @return Response */ public function index(JobProfileRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $page = JobProfile::pushScope(new RequestScope()) ->pushScope(new JobProfileResourceScope()) ->simplePaginate($pageLimit); $data = new JobProfilesCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('career::job_profile.names')) ->view('career::job_profile.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display job_profile. * * @param Request $request * @param Model $job_profile * * @return Response */ public function show(JobProfileRequest $request, JobProfile $model) { $form = $this->form; $modules = $this->modules; $data = new JobProfileResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('career::job_profile.name')) ->data(compact('data', 'form', 'modules')) ->view('career::job_profile.show') ->output(); } /** * Show the form for creating a new job_profile. * * @param Request $request * * @return Response */ public function create(JobProfileRequest $request, JobProfile $model) { $form = $this->form; $modules = $this->modules; $data = new JobProfileResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('career::job_profile.name')) ->view('career::job_profile.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new job_profile. * * @param Request $request * * @return Response */ public function store(JobProfileRequest $request, JobProfile $model) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $model = $model->create($attributes); $data = new JobProfileResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('career::job_profile.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('career/job_profile/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/career/job_profile')) ->redirect(); } } /** * Show job_profile for editing. * * @param Request $request * @param Model $job_profile * * @return Response */ public function edit(JobProfileRequest $request, JobProfile $model) { $form = $this->form; $modules = $this->modules; $data = new JobProfileResource($model); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('career::job_profile.name')) ->view('career::job_profile.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the job_profile. * * @param Request $request * @param Model $job_profile * * @return Response */ public function update(JobProfileRequest $request, JobProfile $model) { try { $attributes = $request->all(); $model = $model->update($attributes); $data = new JobProfileResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('career::job_profile.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('career/job_profile/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('career/job_profile/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the job_profile. * * @param Model $job_profile * * @return Response */ public function destroy(JobProfileRequest $request, JobProfile $model) { try { $model->delete(); $data = new JobProfileResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('career::job_profile.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('career/job_profile/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('career/job_profile/' . $model->getRouteKey())) ->redirect(); } } }