public function digitalCatalogs() { $page = 'produtos'; $websiteSettings = \App\Exceptions\Handler::readFile("websiteSettings.json"); $pages = Pages::where('slug', '=', $page)->first(); $productsCategories = ProductsCategories::orderBy('sortorder', 'asc')->get(); $activePrinciples = Products::addSelect(DB::raw('DISTINCT(activePrinciple)'))->where('activePrinciple', '!=', '')->orderBy('activePrinciple', 'asc')->get(); foreach ($activePrinciples as $activePrinciple) { array_add($activePrinciple, 'activePrincipleSlug', str_slug($activePrinciple->activePrinciple, '-')); } $digitalCatalogs = DigitalCatalogs::orderBy('sortorder', 'asc')->paginate(3); $categoryChosen = "Catálogos Digitais"; $categoryChosenSlug = "catalogos-digitais"; return view('website.products.digitalCatalogs')->with(compact('page', 'pages', 'websiteSettings', 'productsCategories', 'digitalCatalogs', 'categoryChosen', 'categoryChosenSlug', 'activePrinciples', 'activePrincipleChosenSlug')); }
public function deleteCategories(Request $request) { if (!ACL::hasPermission('products', 'delete')) { return redirect(route('productsCategories'))->withErrors(['Você não pode deletar categorias dos produtos.']); } ProductsCategories::deleteProductsByCategory($request->get('productsCategoriesId')); ProductsCategories::find($request->get('productsCategoriesId'))->delete(); $success = "Categoria excluída com sucesso."; return redirect(route('productsCategories'))->with(compact('success')); }