示例#1
0
 /**
  * Feed playlists
  */
 public function feedPlaylists()
 {
     $rows = $this->hasMany('UserRelation', 'follower')->where('active', 1)->select('leader')->findArray();
     if (!$rows) {
         return false;
     }
     // A little eager loading
     $following = array();
     foreach ($rows as $item) {
         $following[] = $item['leader'];
     }
     return Playlist::tableAlias('p')->selectMany('p.*', 'username')->join('user', 'u.id = user_id', 'u')->where('p.published', 1)->whereIn('user_id', $following)->orderByDesc('p.id')->paginate();
 }