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