public function slug($slug) { $post = \App\Models\Posts::where("post_slug", $slug)->first(); $autor = \App\Models\User::where("id", $post->post_autor)->first(); $categoria = \App\Models\Categorias::where("cat_id", $post->post_categoria_id)->get(); $posts = $this->pega_posts(); // Coloca no Thema $pagina = view('base.depoimento', compact('post', 'autor', 'categoria', 'posts')); return view('themes.layout', compact("pagina")); }
public function pega_posts() { $categoria = \App\Models\Categorias::where("cat_slug", 'noticias')->first(); $noticias_categoria_id = $categoria->cat_id; return \App\Models\Posts::where('post_categoria_id', $noticias_categoria_id)->get(); }
/** * DELETANDO CATEGORIA || DELETE CATEGORIA * * @param int $id * @return Response */ public function excluirCategoria($id) { if ($id == '') { return 'erro'; } else { $verCatPost = \App\Models\Posts::where('post_categoria_id', $id)->first(); if (count($verCatPost) > 0) { \App\Models\Posts::where('post_id', $verCatPost->post_id)->update(array('post_categoria_id' => 0)); } $categoria = \App\Models\Categorias::where("cat_id", $id)->delete(); // Excluindo posst if ($categoria) { return 'sucesso'; // Retorna sucesso } // verfica se foi deletado } }