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