예제 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $feedItems = FeedItem::where('processed', '=', false)->get();
     foreach ($feedItems as $feedItem) {
         $feedItem->import();
     }
 }
예제 #2
0
파일: Feed.php 프로젝트: VisualAppeal/stock
 /**
  * Update feed items.
  *
  * @return boolean
  */
 public function updateFeed()
 {
     try {
         $reader = new Reader();
         $lastModified = $this->last_modified_at === null ? null : $this->last_modified_at->toRfc2822String();
         $resource = $reader->download($this->url, $lastModified, $this->etag);
         if (!$resource->isModified()) {
             return true;
         }
         $parser = $reader->getParser($resource->getUrl(), $resource->getContent(), $resource->getEncoding());
         $feed = $parser->execute();
         foreach ($feed->getItems() as $item) {
             $guid = $item->getTag('guid') !== false ? $item->getTag('guid') : $item->getId();
             if (is_array($guid)) {
                 $guid = $guid[0];
             }
             $feedItem = FeedItem::where('feed_id', '=', $this->id)->where('guid', '=', $guid)->first();
             if ($feedItem === null) {
                 $feedItem = new FeedItem();
                 $feedItem->feed_id = $this->id;
                 $feedItem->guid = $guid;
                 $feedItem->title = $item->getTitle();
                 $feedItem->url = $item->getUrl();
                 $feedItem->save();
             }
         }
         $this->last_modified_at = new Carbon($resource->getLastModified());
         $this->etag = $resource->getEtag();
         $this->save();
     } catch (PicoFeedException $e) {
         Log::error($e->getMessage());
         echo $e->getMessage();
         // TODO: Remove debug
         var_dump($e);
         return false;
     }
     return true;
 }
예제 #3
0
 public function view($id)
 {
     $feed = Feed::with(['items', 'items.image'])->findOrFail($id);
     $feedItems = FeedItem::has('image')->paginate(30);
     return view('feed/view', ['pageTitle' => $this->pageTitle([trans('feed.view.page-title', ['title' => $feed->title])]), 'feed' => $feed, 'feedItems' => $feedItems]);
 }