public function show($slug) { $article = Article::where('slug', $slug)->firstOrFail(); $articles = Article::where('published', 1)->whereNotIn('id', [$article->id])->whereHas('categories', function ($query) { $query->where('slug', 'noticias'); })->orderBy('created_at', 'DESC')->take(3)->get(); return view('news.show')->with('article', $article)->with('articles', $articles)->with('author', User::find($article->user_id))->with('currentMenu', 'news'); }
/** * @param $slug * @return $this */ public function show($slug) { $article = Article::where('slug', $slug)->firstOrFail(); $articles = Article::where('published', 1)->whereNotIn('id', [$article->id])->whereHas('categories', function ($query) { $query->where('slug', 'podcast'); })->orderBy('created_at', 'DESC')->take(5)->get(); return view('podcast.show')->with('article', $article)->with('articles', $articles)->with('currentMenu', 'home'); }
public function getArticle($slug) { $data = []; if (Auth::check()) { $data['dashboardAuth'] = 1; } else { $data['auth'] = 1; } $data['general'] = 1; $articles = Article::where('slug', $slug)->select('users.first_name', 'users.id as user_id', 'title', 'slug', 'intro', 'body', 'image', 'articles.created_at')->leftJoin('users', 'users.id', ' =', 'user_id')->take(1)->get()->toArray(); if (!count($articles)) { return view('errors.404'); } foreach ($articles as &$value) { $value['month'] = MyDate::getMonth($value['created_at']); $value['day'] = MyDate::getDay($value['created_at']); $value['spent_days'] = MyDate::getSpentDays($value['created_at']); } $data['article'] = $articles[0]; $data['single'] = 1; return view('frontend.blog.single', $data); }
/** * Show the form for creating a new resource. * * @return Response */ public function news() { // create new feed $feed = Feed::make(); // cache the feed for 60 minutes (second parameter is optional) $feed->setCache(60, 'laravelFeedKey'); // check if there is cached feed and build new only if is not if (!$feed->isCached()) { // creating rss feed with our most recent 20 posts $posts = Article::where('published', 1)->whereHas('categories', function ($query) { $query->where('slug', 'noticias'); })->orderBy('created_at', 'DESC')->get(); // set your feed's title, description, link, pubdate and language $feed->title = 'RSS Noticias'; $feed->description = 'Noticias Laravel RSS'; $feed->logo = 'http://yoursite.tld/logo.jpg'; $feed->link = URL::to('feed'); $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon' $feed->pubdate = $posts[0]->created_at; $feed->lang = 'es'; $feed->setShortening(false); // true or false $feed->setTextLimit(100); // maximum length of description text foreach ($posts as $post) { // set item's title, author, url, pubdate, description and content $feed->add($post->title, $post->author, URL::to("noticias/" . $post->slug), $post->created_at, $post->body, $post->intro); } } // first param is the feed format // optional: second param is cache duration (value of 0 turns off caching) // optional: you can set custom cache key with 3rd param as string return $feed->render('atom'); // to return your feed as a string set second param to -1 // $xml = $feed->render('atom', -1); }