Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {{ CarbonCarbon::parse($noticia->created_at)->format('d/m/Y') }}
- namespace AppModels;
- use IlluminateDatabaseEloquentModel;
- use AppTraitsSluggable;
- class Post extends Model
- {
- use Sluggable;
- protected static $sluggable = 'titulo';
- public static $storage = 'post';
- protected $table = 'post';
- protected $dates = ['periodo_inicio', 'periodo_fim', 'created_at', 'updated_at'];
- protected $fillable = [
- 'id', 'titulo', 'conteudo', 'periodo_inicio', 'periodo_fim', 'imagem', 'qtd_views',
- 'active', 'destaque', 'slug', 'resumo', 'created_at', 'updated_at', 'title_seo', 'description_seo'
- ];
- }
- public function noticiasDetalhe($slug)
- {
- $base_posts_destaques = Post::where('active', 1)->where('destaque', 1)->orderBy('created_at', 'desc')->take(4)->get();
- $noticia = Post::where('slug', $slug)->leftjoin('post_rel_categorias', 'post_rel_categorias.post_id', '=', 'post.id')->first();
- $buscar = '';
- $page_title = '';
- $page_description = '';
- if($noticia) {
- $noticia->update(['qtd_views'=>($noticia->qtd_views + 1)]);
- if($noticia->title_seo != "") {
- $page_title = $noticia->title_seo . " - Berkan";
- } else {
- $page_title = $noticia->titulo . " - Berkan";
- }
- if($noticia->description_seo != "") {
- $page_description = $noticia->description_seo . " - Berkan";
- } else {
- $page_description = $noticia->resumo . " - Berkan";
- }
- $categorias = Post_Categoria::where('active', 1)->get();
- $base_posts = Post::where('post_rel_categorias.post_categoria_id', $noticia->post_categoria_id)
- ->where('post_rel_categorias.id', '<>', $noticia->id)
- ->leftjoin('post_rel_categorias', 'post_rel_categorias.post_id', '=', 'post.id')
- ->select(
- 'post_rel_categorias.id',
- 'post_rel_categorias.post_id',
- 'post.id',
- 'post.titulo',
- 'post.imagem',
- 'post.slug',
- 'post.created_at'
- )->orderBy('created_at', 'desc')->take(3)->get();
- } else {
- abort(404);
- die();
- }
- return view('noticias-detalhe', compact('noticia', 'base_posts_destaques', 'base_posts', 'categorias', 'page_title', 'page_description'));
- }
Add Comment
Please, Sign In to add comment