repository = $career; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\Career\Repositories\Criteria\CareerResourceCriteria::class); } /** * Display a list of career. * * @return Response */ public function index(CareerRequest $request) { return $this->repository ->setPresenter(\Litecms\Career\Repositories\Presenter\CareerPresenter::class) ->paginate(); } /** * Display career. * * @param Request $request * @param Model $career * * @return Response */ public function show(CareerRequest $request, Career $career) { return $career->setPresenter(\Litecms\Career\Repositories\Presenter\CareerListPresenter::class); ; } /** * Create new career. * * @param Request $request * * @return Response */ public function store(CareerRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('career::career.name')]); $code = 204; $status = 'success'; $url = guard_url('career/career/' . $career->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('career/career'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the career. * * @param Request $request * @param Model $career * * @return Response */ public function update(CareerRequest $request, Career $career) { try { $data = $request->all(); $career->update($data); $message = trans('messages.success.updated', ['Module' => trans('career::career.name')]); $code = 204; $status = 'success'; $url = guard_url('career/career/' . $career->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('career/career/' . $career->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the career. * * @param Model $career * * @return Response */ public function destroy(CareerRequest $request, Career $career) { try { $career->delete(); $message = trans('messages.success.deleted', ['Module' => trans('career::career.name')]); $code = 202; $status = 'success'; $url = guard_url('career/career/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('career/career/' . $career->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }