Exemplo n.º 1
0
 /**
  * Show the preview of several news
  * 
  * @return void
  */
 public function showOverview()
 {
     // Internal news are protected and require the "internal" permission:
     $hasAccess = (user() and user()->hasAccess('internal'));
     $newsCollection = News::published()->where('internal', '<=', $hasAccess)->filter()->orderBy('created_at', 'DESC')->take(5)->get();
     $this->pageView('news::show_overview', compact('newsCollection'));
 }
Exemplo n.º 2
0
 public function render($parameters = array())
 {
     // Internal news are protected and require the "internal" permission:
     $hasAccess = (user() and user()->hasAccess('internal'));
     $newsCollection = News::published()->where('internal', '<=', $hasAccess)->orderBy('created_at', 'DESC')->take(5)->get();
     return View::make('news::widget', compact('newsCollection'))->render();
 }
Exemplo n.º 3
0
 public function globalSearch($subject)
 {
     $newsCollection = News::published()->where('title', 'LIKE', '%' . $subject . '%')->get();
     $results = array();
     foreach ($newsCollection as $news) {
         $results[$news->title] = URL::to('news/' . $news->id . '/show');
     }
     return $results;
 }
Exemplo n.º 4
0
 /**
  * Create/update RSS file
  * 
  * @return void
  */
 public static function updateRSS()
 {
     $feed = Rss::feed('2.0', 'UTF-8');
     $feed->channel(['title' => Config::get('app.title') . ' ' . trans('app.object_news'), 'description' => trans('news::rss_last'), 'language' => Lang::getLocale(), 'link' => Config::get('app.url'), 'lastBuildDate' => date('D, j M Y H:i:s ') . 'GMT']);
     $newsCollection = News::published()->orderBy('created_at', 'DESC')->take(20)->get();
     foreach ($newsCollection as $news) {
         $url = URL::route('news.show', $news->id);
         $feed->item(['title' => $news->title, 'description|cdata' => $news->summary, 'link' => $url, 'guid' => $url, 'pubDate' => date('D, j M Y H:i:s ', $news->created_at->timestamp) . 'GMT']);
     }
     $feed->save(public_path() . '/rss/news.xml');
 }