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