form = ProfileForm::setAttributes()->toArray(); $this->modules = $this->modules(config('beo.career.modules'), 'career', guard_url('career')); $this->repository = $profile; } /** * Display a list of profile. * * @return Response */ public function index(ProfileRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $data = $this->repository ->pushFilter(RequestFilter::class) ->pushFilter(ProfileResourceFilter::class) ->setPresenter(ProfileListPresenter::class) ->simplePaginate($pageLimit) // ->withQueryString() ->toArray(); extract($data); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('career::profile.names')) ->view('career::profile.index') ->data(compact('data', 'meta', 'links', 'modules', 'form')) ->output(); } /** * Display profile. * * @param Request $request * @param Model $profile * * @return Response */ public function show(ProfileRequest $request, ProfileRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('career::profile.name')) ->data(compact('data', 'form', 'modules', 'form')) ->view('career::profile.show') ->output(); } /** * Show the form for creating a new profile. * * @param Request $request *x * @return Response */ public function create(ProfileRequest $request, ProfileRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('career::profile.name')) ->view('career::profile.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new profile. * * @param Request $request * * @return Response */ public function store(ProfileRequest $request, ProfileRepositoryInterface $repository) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $repository->create($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.created', ['Module' => trans('career::profile.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('career/profile/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/career/profile')) ->redirect(); } } /** * Show profile for editing. * * @param Request $request * @param Model $profile * * @return Response */ public function edit(ProfileRequest $request, ProfileRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('career::profile.name')) ->view('career::profile.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the profile. * * @param Request $request * @param Model $profile * * @return Response */ public function update(ProfileRequest $request, ProfileRepositoryInterface $repository) { try { $attributes = $request->all(); $repository->update($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.updated', ['Module' => trans('career::profile.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('career/profile/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('career/profile/' . $repository->getRouteKey())) ->redirect(); } } /** * Remove the profile. * * @param Model $profile * * @return Response */ public function destroy(ProfileRequest $request, ProfileRepositoryInterface $repository) { try { $repository->delete(); $data = $repository->toArray(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('career::profile.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('career/profile/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('career/profile/' . $repository->getRouteKey())) ->redirect(); } } }