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) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Bixo\Onboarding\Repositories\Presenter\OnboardingPresenter::class) ->$function(); } $onboardings = $this->repository->paginate(); return $this->response->setMetaTitle(trans('onboarding::onboarding.names')) ->view('onboarding::onboarding.index', true) ->data(compact('onboardings', 'view')) ->output(); } /** * Display onboarding. * * @param Request $request * @param Model $onboarding * * @return Response */ public function show(OnboardingRequest $request, Onboarding $onboarding) { if ($onboarding->exists) { $view = 'onboarding::onboarding.show'; } else { $view = 'onboarding::onboarding.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('onboarding::onboarding.name')) ->data(compact('onboarding')) ->view($view, true) ->output(); } /** * Show the form for creating a new onboarding. * * @param Request $request * * @return Response */ public function create(OnboardingRequest $request) { $onboarding = $this->repository->newInstance([]); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('onboarding::onboarding.name')) ->view('onboarding::onboarding.create', true) ->data(compact('onboarding')) ->output(); } /** * Create new onboarding. * * @param Request $request * * @return Response */ public function store(OnboardingRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $onboarding = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('onboarding::onboarding.name')])) ->code(204) ->status('success') ->url(guard_url('onboarding/onboarding/' . $onboarding->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/onboarding/onboarding')) ->redirect(); } } /** * Show onboarding for editing. * * @param Request $request * @param Model $onboarding * * @return Response */ public function edit(OnboardingRequest $request, Onboarding $onboarding) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('onboarding::onboarding.name')) ->view('onboarding::onboarding.edit', true) ->data(compact('onboarding')) ->output(); } /** * Update the onboarding. * * @param Request $request * @param Model $onboarding * * @return Response */ public function update(OnboardingRequest $request, Onboarding $onboarding) { try { $attributes = $request->all(); $onboarding->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('onboarding::onboarding.name')])) ->code(204) ->status('success') ->url(guard_url('onboarding/onboarding/' . $onboarding->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('onboarding/onboarding/' . $onboarding->getRouteKey())) ->redirect(); } } /** * Remove the onboarding. * * @param Model $onboarding * * @return Response */ public function destroy(OnboardingRequest $request, Onboarding $onboarding) { try { $onboarding->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('onboarding::onboarding.name')])) ->code(202) ->status('success') ->url(guard_url('onboarding/onboarding/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('onboarding/onboarding/' . $onboarding->getRouteKey())) ->redirect(); } } /** * Remove multiple onboarding. * * @param Model $onboarding * * @return Response */ public function delete(OnboardingRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('onboarding::onboarding.name')])) ->status("success") ->code(202) ->url(guard_url('onboarding/onboarding')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/onboarding/onboarding')) ->redirect(); } } /** * Restore deleted onboardings. * * @param Model $onboarding * * @return Response */ public function restore(OnboardingRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('onboarding::onboarding.name')])) ->status("success") ->code(202) ->url(guard_url('/onboarding/onboarding')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/onboarding/onboarding/')) ->redirect(); } } }