public function Blog($post) { $flag = 1; $Sections = null; $Categories = null; $uri = $post; $id_section = DB::table('cms_sections')->where('active', '=', $flag)->where('uri', '=', $uri)->max('id'); $Sections = \App\cms_section::find($id_section); $Categories = DB::table('cms_categories')->where('active', '=', $flag)->where('id_section', '=', $id_section)->get(); $Documents = DB::table('cms_documents')->join('cms_categories', 'cms_documents.id_category', '=', 'cms_categories.id')->join('cms_sections', 'cms_categories.id_section', '=', 'cms_sections.id')->select('cms_documents.*', 'cms_sections.id as id_section', 'cms_sections.title as section', 'cms_categories.title as category')->where('cms_documents.active', '=', $flag)->where('cms_documents.uri', '=', $post)->orderBy('order_by', 'DESC')->get(); $this->aumentarHits($uri); $coments = DB::table('cms_comments')->join('cms_documents', 'cms_documents.id', '=', 'cms_comments.id_document')->select('cms_comments.*', 'cms_documents.id as iddoc')->where('cms_comments.publish', '=', '1')->where('cms_comments.active', '=', '1')->orderby('created_at', 'DESC')->get(); $ContComments = DB::table('cms_comments')->select(DB::raw('count(id) as user_count'))->where('active', '=', 1)->where('publish', '=', 1)->first(); return view('frontend.blog', ['Documents' => $Documents, 'Categories' => $Categories, 'Sections' => $Sections, 'post' => $post, 'coments' => $coments, 'cont' => $ContComments]); }
public function store(Request $request) { $publish = 0; $private = 0; $id_parent = 0; $uri = ""; $id_menu = $request['id_menu']; if ($request['publish'] == 'on') { $publish = 1; } else { $publish = 0; } if ($request['id_parent'] != "") { $id_parent = $request['id_parent']; } /******************************************************/ switch ($request['option']) { case 'LinkTo': if ($request['uri'] != "") { $uri = $request['uri']; } break; case 'LinkToSec': $id_section = $request['id_section_menu']; $Section = \App\cms_section::find($id_section); if ($id_section > 0) { $uri = "Sec/" . $Section->uri; } break; case 'LinkToCatList': $id_section = $request['id_section_menu']; $Section = \App\cms_section::find($id_section); if ($id_section != "") { $uri = "CatList/" . $Section->uri; } break; case 'LinkToCat': $id_category = $request['id_category_menu']; $Category = \App\cms_category::find($id_category); if ($id_category > 0) { $uri = "Cat/" . $Category->uri; } break; case 'LinkToDocList': $id_category = $request['id_category_menu']; $Category = \App\cms_category::find($id_category); if ($id_category != "") { $uri = "DocList/" . $Category->uri; } break; case 'LinkToDoc': $id_document = $request['id_document_menu']; $Document = \App\cms_document::find($id_document); if ($id_document > 0) { $uri = "Doc/" . $Document->uri; } break; case 'LinkToGalList': $id_galleries = 1; $uri = "Galleries"; break; case 'LinkToGallery': $id_galleries = $request['id_galleries']; $Gallery = \App\Media::find($id_galleries); if ($id_galleries > 0) { $uri = "Gal/" . $Gallery->uri; } break; default: return null; } /*******************************************************/ $file = $request->file('file'); if ($file != "") { $path = 'store/MEN/' . uniqid() . '.' . $file->getClientOriginalExtension(); //indicamos que queremos guardar un nuevo archivo en el disco local Storage::disk('local')->put($path, File::get($file)); $ext = $file->getClientOriginalExtension(); } else { $path = ""; $ext = ""; } if ($request['ChekPrivado'] == "on") { $private = 1; } /*******************************************************/ $level = $request['level']; $size = $request['size']; //obtenemos el campo file definido en el formulario $flag = 1; $orderBy = DB::table('men_items')->where('active', '=', $flag)->where('id_menu', '=', $id_menu)->where('id_parent', '=', $id_parent)->max('order_by') + 1; \App\ItemMenu::create(['id_menu' => $id_menu, 'id_parent' => $id_parent, 'title' => $request['title'], 'description' => '', 'size' => $size, 'target' => $request['target'], 'uri' => $uri, 'img' => $path, 'ext' => $ext, 'level' => $level, 'order_by' => $orderBy, 'private' => $private, 'publish' => $publish, 'active' => '1', 'register_by' => Auth::User()->id, 'modify_by' => Auth::User()->id]); return redirect('/admin/itemmenu/' . $id_menu . '/' . $id_parent); }
public function order($id, $orderBy, $no) { // Actualizamos el registro con id $flag = 1; $this->setOrderItem($flag, $orderBy, $no); $Section = \App\cms_section::find($id); $Section->order_by = $no; $Section->save(); return redirect('/admin/sections'); }