repository = $onboarding; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Bixo\Onboarding\Repositories\Criteria\OnboardingResourceCriteria::class); } /** * Display a list of onboarding. * * @return Response */ public function index(OnboardingRequest $request) { return $this->repository ->setPresenter(\Bixo\Onboarding\Repositories\Presenter\OnboardingPresenter::class) ->paginate(); } /** * Display onboarding. * * @param Request $request * @param Model $onboarding * * @return Response */ public function show(OnboardingRequest $request, Onboarding $onboarding) { return $onboarding->setPresenter(\Bixo\Onboarding\Repositories\Presenter\OnboardingListPresenter::class); ; } /** * Create new onboarding. * * @param Request $request * * @return Response */ public function store(OnboardingRequest $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('onboarding::onboarding.name')]); $code = 204; $status = 'success'; $url = guard_url('onboarding/onboarding/' . $onboarding->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('onboarding/onboarding'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the onboarding. * * @param Request $request * @param Model $onboarding * * @return Response */ public function update(OnboardingRequest $request, Onboarding $onboarding) { try { $data = $request->all(); $onboarding->update($data); $message = trans('messages.success.updated', ['Module' => trans('onboarding::onboarding.name')]); $code = 204; $status = 'success'; $url = guard_url('onboarding/onboarding/' . $onboarding->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('onboarding/onboarding/' . $onboarding->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the onboarding. * * @param Model $onboarding * * @return Response */ public function destroy(OnboardingRequest $request, Onboarding $onboarding) { try { $onboarding->delete(); $message = trans('messages.success.deleted', ['Module' => trans('onboarding::onboarding.name')]); $code = 202; $status = 'success'; $url = guard_url('onboarding/onboarding/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('onboarding/onboarding/' . $onboarding->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); } }