本文整理汇总了PHP中Playlist::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Playlist::filter方法的具体用法?PHP Playlist::filter怎么用?PHP Playlist::filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Playlist
的用法示例。
在下文中一共展示了Playlist::filter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: explore
private function explore()
{
// Get some tags to show as options
$tags = Tag::select('name')->limit(30)->findArray();
View::set('tags', $tags);
// No tags selected
if (empty($_GET['t']) || !Validate::tags($_GET['t'])) {
$rows = Playlist::join('user', 'user_id = u.id', 'u')->selectMany('playlist.*', 'username')->where('published', 1)->paginate();
Base::eagerLoadingPlaylistTags($rows);
View::set('playlists', $rows);
View::show('explore');
}
// Separate tags by spaces
$tags = trim($_GET['t']);
$tags = explode('/', $tags, 4);
$tags = array_slice($tags, 0, 3);
// Url for selected tags
$selectedTagsUrl = implode('/', $tags);
// Beautifys the title Tags
$selectedTags = array();
foreach ($tags as $key => $item) {
// Removes empty tags
if (empty($item)) {
unset($tags[$key]);
continue;
}
$aux = array();
$aux['name'] = $item;
// When one clicked will remove that tag from the query
unset($tags[$key]);
$aux['href'] = '/' . implode('/', $tags);
$tags[$key] = $item;
$selectedTags[] = $aux;
}
$playlists = Playlist::filter('byTags', $tags)->join('user', 'p.user_id = u.id', 'u')->selectMany('p.*', 'username');
$count = $playlists->countDistinct('p.id');
$playlists = $playlists->groupBy('p.id')->paginate($count);
Base::eagerLoadingPlaylistTags($playlists);
// View preparations
View::set('playlists', $playlists);
View::set('selectedTags', $selectedTags);
View::set('selectedTagsUrl', $selectedTagsUrl);
View::show('explore');
}
示例2: home
private function home()
{
$this->welcome();
// Staff picks
$staffPicks = Playlist::filter('byTags', 'staff')->select('p.*');
$count = $staffPicks->countDistinct('p.id');
$staffPicks = $staffPicks->groupBy('p.id')->orderByDesc('p.id')->paginate($count);
Base::eagerLoadingPlaylistTags($staffPicks);
View::set('staff_picks', $staffPicks);
// Home tags
$tags = Base::$g['home_tags'];
if (!empty($tags)) {
$tags = explode(', ', $tags);
foreach ($tags as $key => $tag) {
$playlists = Playlist::filter('byTags', $tag)->select('p.*');
$count = $playlists->countDistinct('p.id');
if (!$count) {
unset($tags[$key]);
continue;
}
$playlists = $playlists->groupBy('p.id')->orderByDesc('p.id')->paginate($count);
Base::eagerLoadingPlaylistTags($playlists);
$tags[$key] = $playlists;
$tags[$key]['title'] = $tag;
}
View::set('home_tags_playlists', $tags);
}
// New playlists
$newPlaylists = Playlist::orderByDesc('id')->where('published', 1)->paginate();
Base::eagerLoadingPlaylistTags($newPlaylists);
View::set('new_playlists', $newPlaylists);
if (LOGGED) {
$user = Base::$g['logged'];
// Liked playlists
$likedPlaylists = $user->likedPlaylists();
Base::eagerLoadingPlaylistTags($likedPlaylists);
View::set('liked_playlists', $likedPlaylists);
// Stream
$feedPlaylists = $user->feedPlaylists();
Base::eagerLoadingPlaylistTags($feedPlaylists);
View::set('feed_playlists', $feedPlaylists);
}
View::show('home');
}
示例3: playlist
private function playlist()
{
// Playlist Author
$author = $this->playlist->user();
$author->playlists = $author->playlists();
View::set('author', $author->asArray());
// Tags
$tags = $this->playlist->tags();
View::set('tags', $tags);
// Similar playlists
if ($tags) {
$similarPlaylists = Playlist::filter('byTags', $tags)->select('p.*')->whereNotEqual('p.id', $this->playlist->id);
$count = $similarPlaylists->countDistinct('p.id');
$similarPlaylists = $similarPlaylists->groupBy('p.id')->paginate($count);
// View all link
if ($similarPlaylists) {
$similarPlaylists['href'] = implode('/', $tags);
}
View::set('similar_playlists', $similarPlaylists);
}
// Liked
if (LOGGED) {
$likeActive = PlaylistLike::filter('isActive', $this->playlist->id, LOGGED);
View::set('like_active', $likeActive);
$followDisplay = $this->playlist->user_id !== LOGGED;
View::set('follow_display', $followDisplay);
if ($followDisplay) {
$followActive = UserRelation::filter('isActive', $this->playlist->user_id, LOGGED);
View::set('follow_active', $followActive);
}
$reportActive = Report::filter('isActive', $this->playlist->id, 'playlist', LOGGED);
View::set('report_active', $reportActive);
}
$edit = ADMIN || LOGGED === $this->playlist->user_id;
View::set('edit', $edit);
// View
View::set('playlist', $this->playlist->asArray());
View::set('tracks', $this->playlist->tracks());
View::set('comments', $this->playlist->comments());
View::show('playlist/playlist');
}
示例4: playlists
private function playlists()
{
$playlists = Playlist::filter('bySearchQuery', $this->query)->selectMany('p.*', 'username')->paginate(-1, 6);
Base::eagerLoadingPlaylistTags($playlists);
View::set('playlists', $playlists);
}