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