public static function generateSitemap($reGenerate = false)
 {
     // create new sitemap object
     $sitemap = App::make("sitemap");
     $sitemap->setCache('laravel.sitemap', 3600);
     if ($reGenerate) {
         Cache::forget($sitemap->model->getCacheKey());
     }
     // check if there is cached sitemap and build new only if is not
     if (!$sitemap->isCached()) {
         // add item to the sitemap (url, date, priority, freq)
         $sitemap->add(URL::to('/'), null, '1.0', 'daily');
         $categories = Category::get();
         foreach ($categories as $category) {
             $sitemap->add(URL::route('category', [$category->slug]), null, '1.0', 'daily');
         }
         // get all lists from db
         $lists = ViralList::orderBy('created_at', 'desc')->get();
         // add every post to the sitemap
         foreach ($lists as $list) {
             $sitemap->add(ListHelpers::viewListUrl($list), $list->updated_at, '1.0', 'monthly');
         }
     }
     // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
     return $sitemap->render('xml');
 }
 public function listLists()
 {
     $search = Input::get('search', null);
     $filterStatus = Input::get('status', null);
     $sortOptions = self::processSort();
     $listsQuery = ViralList::orderBy($sortOptions['sort'], $sortOptions['sortType']);
     if ($search) {
         $listsQuery->where('topic', 'like', '%' . $search . '%');
     }
     if ($filterStatus) {
         $listsQuery->where('status', $filterStatus);
         if ($filterStatus == 'awaiting_approval') {
             $listsQuery->orHas('pendingChanges');
         }
     }
     $lists = $listsQuery->paginate(self::$perPage);
     if ($search) {
         $lists->appends(['search' => $search]);
     }
     //dd(DB::getQueryLog());
     return View::make('admin/lists/view')->with(array('lists' => $lists, 'search' => $search));
 }
 public static function generateRssFeed()
 {
     $config = Config::get('siteConfig');
     // create new feed
     $feed = Feed::make();
     // cache the feed for 10 minutes (second parameter is optional)
     $feed->setCache(10, 'list-rss-feed');
     // 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
         $lists = ViralList::orderBy('created_at', 'desc')->take(20)->get();
         // set your feed's title, description, link, pubdate and language
         $feed->title = $config['main']['siteTitle'];
         $feed->description = @$config['main']['siteDescription'];
         $feed->logo = @asset($config['main']['logo']);
         $feed->link = URL::route('rssFeed');
         $feed->setDateFormat('datetime');
         // 'datetime', 'timestamp' or 'carbon'
         $feed->pubdate = $lists->count() ? $lists[0]->created_at : time();
         $feed->lang = $config['languages']['activeLanguage'];
         $feed->setShortening(true);
         // true or false
         $feed->setTextLimit(100);
         // maximum length of description text
         foreach ($lists as $list) {
             // set item's title, author, url, pubdate, description and content
             $listContentHtml = View::make('lists.rssFeedListContent', ['list' => $list]);
             $feed->add($list->title, $list->creator->name, ListHelpers::viewListUrl($list), $list->created_at->toDateTimeString(), $list->description, $listContentHtml);
         }
     }
     // 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('rss');
     // to return your feed as a string set second param to -1
     // $xml = $feed->render('atom', -1);
 }