mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-01-31 03:16:42 +01:00
Added is listed feature
This commit is contained in:
parent
675ba17901
commit
cca292049e
10 changed files with 43 additions and 6 deletions
|
@ -57,7 +57,7 @@
|
|||
if (!$user)
|
||||
App::abort(404);
|
||||
|
||||
$query = Track::summary()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at');
|
||||
$query = Track::summary()->published()->listed()->explicitFilter()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at');
|
||||
$tracks = [];
|
||||
$singles = [];
|
||||
|
||||
|
@ -88,7 +88,7 @@
|
|||
if (!$user)
|
||||
App::abort(404);
|
||||
|
||||
$trackQuery = Track::summary()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at')->orderBy('created_at', 'desc')->take(20);
|
||||
$trackQuery = Track::summary()->published()->explicitFilter()->listed()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at')->orderBy('created_at', 'desc')->take(20);
|
||||
$latestTracks = [];
|
||||
|
||||
foreach ($trackQuery->get() as $track) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
$recentQuery = Track::summary()
|
||||
->with(['genre', 'user', 'cover', 'user.avatar'])
|
||||
->whereIsLatest(true)
|
||||
->listed()
|
||||
->userDetails()
|
||||
->explicitFilter()
|
||||
->published()
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
$query = Track::summary()
|
||||
->userDetails()
|
||||
->listed()
|
||||
->explicitFilter()
|
||||
->published()
|
||||
->with('user', 'genre', 'cover', 'album', 'album.user');
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class TrackIsListed extends Migration {
|
||||
public function up() {
|
||||
Schema::table('tracks', function($table) {
|
||||
$table->boolean('is_listed')->notNullable()->indexed();
|
||||
});
|
||||
|
||||
DB::update('
|
||||
UPDATE
|
||||
tracks
|
||||
SET
|
||||
is_listed = true');
|
||||
}
|
||||
|
||||
public function down() {
|
||||
Schema::table('tracks', function($table) {
|
||||
$table->dropColumn('is_listed');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -70,6 +70,7 @@
|
|||
$track->track_type_id = $this->_input['track_type_id'];
|
||||
$track->is_explicit = $this->_input['is_explicit'] == 'true';
|
||||
$track->is_downloadable = $this->_input['is_downloadable'] == 'true';
|
||||
$track->is_listed = $this->_input['is_listed'] == 'true';
|
||||
$track->is_vocal = $isVocal;
|
||||
|
||||
if (isset($this->_input['album_id']) && strlen(trim($this->_input['album_id']))) {
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
$track->user_id = $user->id;
|
||||
$track->title = pathinfo($trackFile->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
$track->duration = $audio->getDuration();
|
||||
$track->is_listed = true;
|
||||
|
||||
$track->save();
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@
|
|||
$query->whereNotNull('published_at');
|
||||
}
|
||||
|
||||
public function scopeListed($query) {
|
||||
$query->whereIsListed(true);
|
||||
}
|
||||
|
||||
public function scopeExplicitFilter($query) {
|
||||
if (!Auth::check() || !Auth::user()->can_see_explicit_content)
|
||||
$query->whereIsExplicit(false);
|
||||
|
@ -60,6 +64,7 @@
|
|||
$trackIds = Cache::remember('popular_tracks' . $count . '-' . ($allowExplicit ? 'explicit' : 'safe'), 5, function() use ($allowExplicit, $count) {
|
||||
$query = static
|
||||
::published()
|
||||
->listed()
|
||||
->join(DB::raw('
|
||||
( SELECT `track_id`, `created_at`
|
||||
FROM `resource_log_items`
|
||||
|
@ -249,7 +254,8 @@
|
|||
'duration' => $track->duration,
|
||||
'genre_id' => $track->genre_id,
|
||||
'track_type_id' => $track->track_type_id,
|
||||
'cover_url' => $track->getCoverUrl(Image::SMALL)
|
||||
'cover_url' => $track->getCoverUrl(Image::SMALL),
|
||||
'is_listed' => !!$track->is_listed
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
return $this->email;
|
||||
}
|
||||
|
||||
public function setDisplayName($value) {
|
||||
public function setDisplayNameAttribute($value) {
|
||||
$this->attributes['display_name'] = $value;
|
||||
$this->attributes['slug'] = Str::slug($value);
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ angular.module('ponyfm').controller "account-track", [
|
|||
cover: track.cover_url
|
||||
album_id: track.album_id
|
||||
is_published: track.is_published
|
||||
is_listed: track.is_listed
|
||||
|
||||
$scope.selectedAlbum = if track.album_id then albumsDb[track.album_id] else null
|
||||
$scope.selectedSongs = {}
|
||||
|
|
|
@ -91,12 +91,15 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span6 form-row">
|
||||
<div class="span4 form-row">
|
||||
<label for="is_explicit"><input ng-disabled="isSaving" ng-change="touchModel()" id="is_explicit" type="checkbox" ng-model="edit.is_explicit" /> Contains Explicit Content</label>
|
||||
</div>
|
||||
<div class="span6 form-row">
|
||||
<div class="span4 form-row">
|
||||
<label for="is_downloadable"><input ng-disabled="isSaving" ng-change="touchModel()" id="is_downloadable" type="checkbox" ng-model="edit.is_downloadable" /> Is Downloadable</label>
|
||||
</div>
|
||||
<div class="span4 form-row">
|
||||
<label for="is_listed"><input ng-disabled="isSaving" ng-change="touchModel()" id="is_listed" type="checkbox" ng-model="edit.is_listed" /> Is Listed</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label class="strong">Choose a License:</label>
|
||||
|
|
Loading…
Reference in a new issue