Lots of minor code cleanup.

This commit is contained in:
Peter Deltchev 2016-06-05 23:15:56 -07:00
parent b46ba956d0
commit 9a9ac7e5a1
36 changed files with 58 additions and 117 deletions

View file

@ -35,13 +35,13 @@ class AlbumDownloader
*/ */
private $_format; private $_format;
function __construct($album, $format) public function __construct($album, $format)
{ {
$this->_album = $album; $this->_album = $album;
$this->_format = $format; $this->_format = $format;
} }
function download() public function download()
{ {
$zip = new ZipStream($this->_album->user->display_name.' - '.$this->_album->title.'.zip'); $zip = new ZipStream($this->_album->user->display_name.' - '.$this->_album->title.'.zip');
$zip->setComment( $zip->setComment(

View file

@ -34,7 +34,7 @@ class AddTrackToPlaylistCommand extends CommandBase
/** @var Playlist */ /** @var Playlist */
private $_playlist; private $_playlist;
function __construct($playlistId, $trackId) public function __construct($playlistId, $trackId)
{ {
$this->_playlist = Playlist::find($playlistId); $this->_playlist = Playlist::find($playlistId);
$this->_track = Track::find($trackId); $this->_track = Track::find($trackId);

View file

@ -29,7 +29,7 @@ class CreateAlbumCommand extends CommandBase
{ {
private $_input; private $_input;
function __construct($input) public function __construct($input)
{ {
$this->_input = $input; $this->_input = $input;
} }

View file

@ -35,7 +35,7 @@ class CreateCommentCommand extends CommandBase
private $_id; private $_id;
private $_type; private $_type;
function __construct($type, $id, $input) public function __construct($type, $id, $input)
{ {
$this->_input = $input; $this->_input = $input;
$this->_id = $id; $this->_id = $id;

View file

@ -29,7 +29,7 @@ class CreatePlaylistCommand extends CommandBase
{ {
private $_input; private $_input;
function __construct($input) public function __construct($input)
{ {
$this->_input = $input; $this->_input = $input;
} }

View file

@ -31,7 +31,7 @@ class DeleteAlbumCommand extends CommandBase
/** @var Album */ /** @var Album */
private $_album; private $_album;
function __construct($albumId) public function __construct($albumId)
{ {
$this->_albumId = $albumId; $this->_albumId = $albumId;
$this->_album = Album::find($albumId); $this->_album = Album::find($albumId);

View file

@ -31,7 +31,7 @@ class DeletePlaylistCommand extends CommandBase
/** @var Playlist */ /** @var Playlist */
private $_playlist; private $_playlist;
function __construct($playlistId) public function __construct($playlistId)
{ {
$this->_playlistId = $playlistId; $this->_playlistId = $playlistId;
$this->_playlist = Playlist::find($playlistId); $this->_playlist = Playlist::find($playlistId);

View file

@ -31,7 +31,7 @@ class DeleteTrackCommand extends CommandBase
/** @var Track */ /** @var Track */
private $_track; private $_track;
function __construct($trackId) public function __construct($trackId)
{ {
$this->_trackId = $trackId; $this->_trackId = $trackId;
$this->_track = Track::find($trackId); $this->_track = Track::find($trackId);

View file

@ -36,7 +36,7 @@ class EditAlbumCommand extends CommandBase
/** @var Album */ /** @var Album */
private $_album; private $_album;
function __construct($trackId, $input) public function __construct($trackId, $input)
{ {
$this->_input = $input; $this->_input = $input;
$this->_albumId = $trackId; $this->_albumId = $trackId;

View file

@ -31,7 +31,7 @@ class EditPlaylistCommand extends CommandBase
private $_playlistId; private $_playlistId;
private $_playlist; private $_playlist;
function __construct($playlistId, $input) public function __construct($playlistId, $input)
{ {
$this->_input = $input; $this->_input = $input;
$this->_playlistId = $playlistId; $this->_playlistId = $playlistId;

View file

@ -40,7 +40,7 @@ class EditTrackCommand extends CommandBase
private $_track; private $_track;
private $_input; private $_input;
function __construct($trackId, $input) public function __construct($trackId, $input)
{ {
$this->_trackId = $trackId; $this->_trackId = $trackId;
$this->_track = Track::find($trackId); $this->_track = Track::find($trackId);

View file

@ -39,7 +39,7 @@ class MergeAccountsCommand extends CommandBase
private $sourceAccount; private $sourceAccount;
private $destinationAccount; private $destinationAccount;
function __construct(User $sourceAccount, User $destinationAccount) public function __construct(User $sourceAccount, User $destinationAccount)
{ {
$this->sourceAccount = $sourceAccount; $this->sourceAccount = $sourceAccount;
$this->destinationAccount = $destinationAccount; $this->destinationAccount = $destinationAccount;

View file

@ -33,7 +33,7 @@ class SaveAccountSettingsCommand extends CommandBase
private $_user; private $_user;
private $_current; private $_current;
function __construct($input, $slug) public function __construct($input, $slug)
{ {
$this->_input = $input; $this->_input = $input;
$this->_slug = $slug; $this->_slug = $slug;

View file

@ -34,7 +34,7 @@ class ToggleFavouriteCommand extends CommandBase
private $_resourceType; private $_resourceType;
private $_resourceId; private $_resourceId;
function __construct($resourceType, $resourceId) public function __construct($resourceType, $resourceId)
{ {
$this->_resourceId = $resourceId; $this->_resourceId = $resourceId;
$this->_resourceType = $resourceType; $this->_resourceType = $resourceType;

View file

@ -30,7 +30,7 @@ class ToggleFollowingCommand extends CommandBase
private $_resourceType; private $_resourceType;
private $_resourceId; private $_resourceId;
function __construct($resourceType, $resourceId) public function __construct($resourceType, $resourceId)
{ {
$this->_resourceId = $resourceId; $this->_resourceId = $resourceId;
$this->_resourceType = $resourceType; $this->_resourceType = $resourceType;

View file

@ -41,7 +41,6 @@ class BootstrapLocalEnvironment extends Command
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void
*/ */
public function __construct() public function __construct()
{ {

View file

@ -48,7 +48,6 @@ class FixMLPMAImages extends Command
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void
*/ */
public function __construct() public function __construct()
{ {

View file

@ -58,7 +58,6 @@ class MergeAccounts extends Command
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void
*/ */
public function __construct() public function __construct()
{ {

View file

@ -44,7 +44,6 @@ class PoniverseApiSetup extends Command
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void
*/ */
public function __construct() public function __construct()
{ {

View file

@ -42,7 +42,6 @@ class RebuildArtists extends Command
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void
*/ */
public function __construct() public function __construct()
{ {

View file

@ -47,7 +47,6 @@ class RebuildSearchIndex extends Command
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void
*/ */
public function __construct() public function __construct()
{ {

View file

@ -49,7 +49,6 @@ class RebuildTrack extends Command
/** /**
* Create a new command instance. * Create a new command instance.
* *
* @return void
*/ */
public function __construct() public function __construct()
{ {

View file

@ -49,7 +49,7 @@ class PlaylistsController extends ApiControllerBase
public function postDelete($id) public function postDelete($id)
{ {
return $this->execute(new DeletePlaylistCommand($id, Input::all())); return $this->execute(new DeletePlaylistCommand($id));
} }
public function postAddTrack($id) public function postAddTrack($id)

View file

@ -137,8 +137,6 @@ class TracksController extends ApiControllerBase
$page = Input::get('page'); $page = Input::get('page');
} }
$query = null;
if ($all) { if ($all) {
$query = Track::summary() $query = Track::summary()
->userDetails() ->userDetails()

View file

@ -60,7 +60,6 @@ class DisabledAccountCheck
&& !($request->getMethod() === 'POST' && $request->getRequestUri() == '/auth/logout') && !($request->getMethod() === 'POST' && $request->getRequestUri() == '/auth/logout')
) { ) {
$this->auth->logout(); $this->auth->logout();
// return Response::view('home.account-disabled', ['username' => $this->auth->user()->username], 403);
} }
return $next($request); return $next($request);

View file

@ -35,8 +35,7 @@ class RedirectIfAuthenticated
/** /**
* Create a new filter instance. * Create a new filter instance.
* *
* @param Guard $auth * @param Guard $auth
* @return void
*/ */
public function __construct(Guard $auth) public function __construct(Guard $auth)
{ {

View file

@ -132,9 +132,6 @@ Route::group(['prefix' => 'api/web'], function() {
Route::post('/follow/toggle', 'Api\Web\FollowController@postToggle'); Route::post('/follow/toggle', 'Api\Web\FollowController@postToggle');
Route::post('/dashboard/read-news', 'Api\Web\DashboardController@postReadNews'); Route::post('/dashboard/read-news', 'Api\Web\DashboardController@postReadNews');
});
Route::group(['middleware' => 'auth'], function() {
Route::get('/account/settings/{slug}', 'Api\Web\AccountController@getSettings'); Route::get('/account/settings/{slug}', 'Api\Web\AccountController@getSettings');
Route::get('/notifications', 'Api\Web\NotificationsController@getNotifications'); Route::get('/notifications', 'Api\Web\NotificationsController@getNotifications');
Route::put('/notifications/mark-as-read', 'Api\Web\NotificationsController@putMarkAsRead'); Route::put('/notifications/mark-as-read', 'Api\Web\NotificationsController@putMarkAsRead');
@ -142,7 +139,7 @@ Route::group(['prefix' => 'api/web'], function() {
Route::get('/tracks/owned', 'Api\Web\TracksController@getOwned'); Route::get('/tracks/owned', 'Api\Web\TracksController@getOwned');
Route::get('/tracks/edit/{id}', 'Api\Web\TracksController@getEdit'); Route::get('/tracks/edit/{id}', 'Api\Web\TracksController@getEdit');
Route::get('/users/{userId}', 'Api\Web\AccountController@getUser');//->where('userId', '\d+'); Route::get('/users/{userId}', 'Api\Web\AccountController@getUser')->where('userId', '\d+');
Route::get('/users/{userId}/albums', 'Api\Web\AlbumsController@getOwned')->where('id', '\d+'); Route::get('/users/{userId}/albums', 'Api\Web\AlbumsController@getOwned')->where('id', '\d+');
Route::get('/users/{userId}/images', 'Api\Web\ImagesController@getOwned')->where('id', '\d+'); Route::get('/users/{userId}/images', 'Api\Web\ImagesController@getOwned')->where('id', '\d+');
@ -210,6 +207,4 @@ Route::get('/', 'HomeController@getIndex');
Route::group(['domain' => 'api.pony.fm'], function() { Route::group(['domain' => 'api.pony.fm'], function() {
Route::get('tracks/latest', ['uses' => 'Api\Mobile\TracksController@latest']); Route::get('tracks/latest', ['uses' => 'Api\Mobile\TracksController@latest']);
Route::get('tracks/popular', [ 'uses' => 'Api\Mobile\TracksController@popular']); Route::get('tracks/popular', [ 'uses' => 'Api\Mobile\TracksController@popular']);
/* Route::get('tracks/id', [ 'uses' => 'Api\Mobile\TracksController@track']);
Route::get('user', ['uses' => 'Api\Mobile\UserController@user']);*/
}); });

View file

@ -98,27 +98,27 @@ class Album extends Model implements Searchable, Commentable, Favouritable
public function user() public function user()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\User'); return $this->belongsTo(User::class);
} }
public function users() public function users()
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\ResourceUser'); return $this->hasMany(ResourceUser::class);
} }
public function favourites():HasMany public function favourites():HasMany
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\Favourite'); return $this->hasMany(Favourite::class);
} }
public function cover() public function cover()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Image'); return $this->belongsTo(Image::class);
} }
public function tracks() public function tracks()
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\Track')->orderBy('track_number', 'asc'); return $this->hasMany(Track::class)->orderBy('track_number', 'asc');
} }
public function trackFiles() { public function trackFiles() {
@ -127,7 +127,7 @@ class Album extends Model implements Searchable, Commentable, Favouritable
public function comments():HasMany public function comments():HasMany
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\Comment')->orderBy('created_at', 'desc'); return $this->hasMany(Comment::class)->orderBy('created_at', 'desc');
} }
public function activities():MorphMany { public function activities():MorphMany {

View file

@ -60,27 +60,27 @@ class Comment extends Model
public function user() public function user()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\User'); return $this->belongsTo(User::class);
} }
public function track() public function track()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Track'); return $this->belongsTo(Track::class);
} }
public function album() public function album()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Album'); return $this->belongsTo(Album::class);
} }
public function playlist() public function playlist()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Playlist'); return $this->belongsTo(Playlist::class);
} }
public function profile() public function profile()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\User', 'profile_id'); return $this->belongsTo(User::class, 'profile_id');
} }
public function activities():MorphMany public function activities():MorphMany

View file

@ -51,22 +51,22 @@ class Favourite extends Model
public function user() public function user()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\User'); return $this->belongsTo(User::class);
} }
public function track() public function track()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Track'); return $this->belongsTo(Track::class);
} }
public function album() public function album()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Album'); return $this->belongsTo(Album::class);
} }
public function playlist() public function playlist()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Playlist'); return $this->belongsTo(Playlist::class);
} }
/** /**

View file

@ -39,11 +39,11 @@ class PinnedPlaylist extends Model
public function user() public function user()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\User'); return $this->belongsTo(User::class);
} }
public function playlist() public function playlist()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Playlist'); return $this->belongsTo(Playlist::class);
} }
} }

View file

@ -201,7 +201,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
public function tracks() public function tracks()
{ {
return $this return $this
->belongsToMany('Poniverse\Ponyfm\Models\Track') ->belongsToMany(Track::class)
->withPivot('position') ->withPivot('position')
->withTimestamps() ->withTimestamps()
->orderBy('position', 'asc'); ->orderBy('position', 'asc');
@ -215,17 +215,17 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
public function users() public function users()
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\ResourceUser'); return $this->hasMany(ResourceUser::class);
} }
public function comments():HasMany public function comments():HasMany
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\Comment')->orderBy('created_at', 'desc'); return $this->hasMany(Comment::class)->orderBy('created_at', 'desc');
} }
public function pins() public function pins()
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\PinnedPlaylist'); return $this->hasMany(PinnedPlaylist::class);
} }
public function favourites():HasMany { public function favourites():HasMany {
@ -234,7 +234,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
public function user() public function user()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\User'); return $this->belongsTo(User::class);
} }
public function activities():MorphMany { public function activities():MorphMany {

View file

@ -486,52 +486,52 @@ class Track extends Model implements Searchable, Commentable, Favouritable
public function genre() public function genre()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Genre'); return $this->belongsTo(Genre::class);
} }
public function trackType() public function trackType()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\TrackType', 'track_type_id'); return $this->belongsTo(TrackType::class, 'track_type_id');
} }
public function comments():HasMany public function comments():HasMany
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\Comment')->orderBy('created_at', 'desc'); return $this->hasMany(Comment::class)->orderBy('created_at', 'desc');
} }
public function favourites():HasMany public function favourites():HasMany
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\Favourite'); return $this->hasMany(Favourite::class);
} }
public function cover() public function cover()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Image'); return $this->belongsTo(Image::class);
} }
public function showSongs() public function showSongs()
{ {
return $this->belongsToMany('Poniverse\Ponyfm\Models\ShowSong'); return $this->belongsToMany(ShowSong::class);
} }
public function users() public function users()
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\ResourceUser'); return $this->hasMany(ResourceUser::class);
} }
public function user() public function user()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\User'); return $this->belongsTo(User::class);
} }
public function album() public function album()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Album'); return $this->belongsTo(Album::class);
} }
public function trackFiles() public function trackFiles()
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\TrackFile'); return $this->hasMany(TrackFile::class);
} }
public function notifications() public function notifications()

View file

@ -153,7 +153,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
$user->username = $username; $user->username = $username;
$user->display_name = $displayName; $user->display_name = $displayName;
$user->slug = static::getUniqueSlugForName($displayName); $user->slug = self::getUniqueSlugForName($displayName);
$user->email = $email; $user->email = $email;
$user->uses_gravatar = true; $user->uses_gravatar = true;
$user->save(); $user->save();
@ -164,12 +164,12 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
public function avatar() public function avatar()
{ {
return $this->belongsTo('Poniverse\Ponyfm\Models\Image'); return $this->belongsTo(Image::class);
} }
public function users() public function users()
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\ResourceUser', 'artist_id'); return $this->hasMany(ResourceUser::class, 'artist_id');
} }
public function followers() public function followers()
@ -184,12 +184,12 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
public function comments():HasMany public function comments():HasMany
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\Comment', 'profile_id')->orderBy('created_at', 'desc'); return $this->hasMany(Comment::class, 'profile_id')->orderBy('created_at', 'desc');
} }
public function tracks() public function tracks()
{ {
return $this->hasMany('Poniverse\Ponyfm\Models\Track', 'user_id'); return $this->hasMany(Track::class, 'user_id');
} }
public function notifications() public function notifications()

View file

@ -35,13 +35,13 @@ class PlaylistDownloader
*/ */
private $_format; private $_format;
function __construct($playlist, $format) public function __construct($playlist, $format)
{ {
$this->_playlist = $playlist; $this->_playlist = $playlist;
$this->_format = $format; $this->_format = $format;
} }
function download() public function download()
{ {
$zip = new ZipStream($this->_playlist->user->display_name.' - '.$this->_playlist->title.'.zip'); $zip = new ZipStream($this->_playlist->user->display_name.' - '.$this->_playlist->title.'.zip');
$zip->setComment( $zip->setComment(

View file

@ -1,43 +0,0 @@
{{--
Pony.fm - A community for pony fan music.
Copyright (C) 2015 Peter Deltchev
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--}}<html>
<head>
<title>Account disabled :: Pony.fm</title>
<style>
body {
font-family: sans-serif;
width: 400px;
margin: 2em auto;
}
button {
font-size: 20px;
padding: 0.4em;
}
</style>
</head>
<body>
<h1>Account disabled</h1>
<p>Your Pony.fm account, {{ $username }}, has been disabled.</p>
<p>If you believe this to be in error,
contact <a href="mailto:feld0@pony.fm" target="_blank">feld0@pony.fm</a>.</p>
<p><form action="/auth/logout" method="POST">
<button>Log out</button>
{{ csrf_field() }}
</form></p>
</body>
</html>