Exemple #1
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();
 }
 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;
 }
Exemple #3
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');
 }