Exemplo n.º 1
0
 public function feed($limit = static::LIMIT)
 {
     $feed = 0;
     try {
         $feed = $this->getFeed($limit);
         $feed = array_map(function ($f) {
             $providerId = $f->{$this->idField};
             if ($this->useCache) {
                 return Cache::remember("{$this->provides}_post_{$providerId}", 10, function () {
                     return $this->post($providerId);
                 });
             }
             return $this->post($providerId);
         }, $feed);
     } catch (\Exception $e) {
         // TODO: logging
         $feed = Post::whereUserId(Auth::id())->whereProvider($this->provides)->limit($limit)->get();
     }
     return collect($feed);
 }
Exemplo n.º 2
0
 public function index()
 {
     $input = $this->request->only(['provider', 'start', 'end']);
     return Post::whereUserId($this->auth->id())->whereProvider($input['provider'])->whereBetween('posted_at', array($input['start'], $input['end']))->where('posted_at', '>', date('Y-m-d H:i:s'))->latest()->get(['id', 'text as title', 'posted_at as start', 'image', 'link', 'provider']);
 }