middleware(function ($request, $next) { $this->form = NicheUserForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('bixo.niche.modules'), 'niche', guard_url('niche')); return $next($request); }); } /** * Display a list of niche_user. * * @return Response */ public function index(NicheUserResourceRequest $request) { $request = $request->all(); $page = NicheUserActions::run('paginate', $request); $data = new NicheUsersCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('niche::niche_user.names')) ->view('niche::niche_user.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display niche_user. * * @param Request $request * @param Model $niche_user * * @return Response */ public function show(NicheUserResourceRequest $request, NicheUser $model) { $form = $this->form; $modules = $this->modules; $data = new NicheUserResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('niche::niche_user.name')) ->data(compact('data', 'form', 'modules')) ->view('niche::niche_user.show') ->output(); } /** * Show the form for creating a new niche_user. * * @param Request $request * * @return Response */ public function create(NicheUserResourceRequest $request, NicheUser $model) { $form = $this->form; $modules = $this->modules; $data = new NicheUserResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('niche::niche_user.name')) ->view('niche::niche_user.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new niche_user. * * @param Request $request * * @return Response */ public function store(NicheUserResourceRequest $request, NicheUser $model) { try { $request = $request->all(); $model = NicheUserAction::run('store', $model, $request); $data = new NicheUserResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('niche::niche_user.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('niche/niche_user/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/niche/niche_user')) ->redirect(); } } /** * Show niche_user for editing. * * @param Request $request * @param Model $niche_user * * @return Response */ public function edit(NicheUserResourceRequest $request, NicheUser $model) { $form = $this->form; $modules = $this->modules; $data = new NicheUserResource($model); // return view('niche::niche_user.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('niche::niche_user.name')) ->view('niche::niche_user.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the niche_user. * * @param Request $request * @param Model $niche_user * * @return Response */ public function update(NicheUserResourceRequest $request, NicheUser $model) { try { $request = $request->all(); $model = NicheUserAction::run('update', $model, $request); $data = new NicheUserResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('niche::niche_user.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('niche/niche_user/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('niche/niche_user/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the niche_user. * * @param Model $niche_user * * @return Response */ public function destroy(NicheUserResourceRequest $request, NicheUser $model) { try { $request = $request->all(); $model = NicheUserAction::run('destroy', $model, $request); $data = new NicheUserResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('niche::niche_user.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('niche/niche_user/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('niche/niche_user/' . $model->getRouteKey())) ->redirect(); } } }