Merge pull request #152 from Poniverse/shift-40784

This commit is contained in:
Adam Lavin 2021-02-14 19:52:46 +00:00 committed by GitHub
commit 4ff293dd39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
115 changed files with 632 additions and 648 deletions

View file

@ -22,9 +22,9 @@ namespace App\Commands;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\Track; use App\Models\Track;
use Auth; use Illuminate\Support\Facades\Auth;
use DB; use Illuminate\Support\Facades\DB;
use Validator; use Illuminate\Support\Facades\Validator;
class AddTrackToPlaylistCommand extends CommandBase class AddTrackToPlaylistCommand extends CommandBase
{ {

View file

@ -23,9 +23,9 @@ namespace App\Commands;
use App\Models\Album; use App\Models\Album;
use App\Models\Image; use App\Models\Image;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Support\Facades\Auth;
use Gate; use Illuminate\Support\Facades\Gate;
use Validator; use Illuminate\Support\Facades\Validator;
class CreateAlbumCommand extends CommandBase class CreateAlbumCommand extends CommandBase
{ {

View file

@ -21,8 +21,8 @@
namespace App\Commands; namespace App\Commands;
use App\Models\Announcement; use App\Models\Announcement;
use Gate; use Illuminate\Support\Facades\Gate;
use Validator; use Illuminate\Support\Facades\Validator;
class CreateAnnouncementCommand extends CommandBase class CreateAnnouncementCommand extends CommandBase
{ {

View file

@ -25,9 +25,9 @@ use App\Models\Comment;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Support\Facades\Auth;
use Notification; use Illuminate\Support\Facades\Notification;
use Validator; use Illuminate\Support\Facades\Validator;
class CreateCommentCommand extends CommandBase class CreateCommentCommand extends CommandBase
{ {

View file

@ -21,9 +21,9 @@
namespace App\Commands; namespace App\Commands;
use App\Models\Genre; use App\Models\Genre;
use Gate; use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Validator;
class CreateGenreCommand extends CommandBase class CreateGenreCommand extends CommandBase
{ {

View file

@ -21,9 +21,9 @@
namespace App\Commands; namespace App\Commands;
use App\Models\Playlist; use App\Models\Playlist;
use Auth; use Illuminate\Support\Facades\Auth;
use Notification; use Illuminate\Support\Facades\Notification;
use Validator; use Illuminate\Support\Facades\Validator;
class CreatePlaylistCommand extends CommandBase class CreatePlaylistCommand extends CommandBase
{ {

View file

@ -21,9 +21,9 @@
namespace App\Commands; namespace App\Commands;
use App\Models\ShowSong; use App\Models\ShowSong;
use Gate; use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Validator;
class CreateShowSongCommand extends CommandBase class CreateShowSongCommand extends CommandBase
{ {

View file

@ -21,8 +21,8 @@
namespace App\Commands; namespace App\Commands;
use App\Models\User; use App\Models\User;
use Gate; use Illuminate\Support\Facades\Gate;
use Validator; use Illuminate\Support\Facades\Validator;
class CreateUserCommand extends CommandBase class CreateUserCommand extends CommandBase
{ {

View file

@ -21,8 +21,8 @@
namespace App\Commands; namespace App\Commands;
use App\Models\Album; use App\Models\Album;
use Auth; use Illuminate\Support\Facades\Auth;
use Gate; use Illuminate\Support\Facades\Gate;
class DeleteAlbumCommand extends CommandBase class DeleteAlbumCommand extends CommandBase
{ {

View file

@ -22,9 +22,9 @@ namespace App\Commands;
use App\Jobs\DeleteGenre; use App\Jobs\DeleteGenre;
use App\Models\Genre; use App\Models\Genre;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Validator; use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
class DeleteGenreCommand extends CommandBase class DeleteGenreCommand extends CommandBase
{ {

View file

@ -21,7 +21,7 @@
namespace App\Commands; namespace App\Commands;
use App\Models\Playlist; use App\Models\Playlist;
use Auth; use Illuminate\Support\Facades\Auth;
class DeletePlaylistCommand extends CommandBase class DeletePlaylistCommand extends CommandBase
{ {

View file

@ -22,9 +22,9 @@ namespace App\Commands;
use App\Jobs\DeleteShowSong; use App\Jobs\DeleteShowSong;
use App\Models\ShowSong; use App\Models\ShowSong;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Validator; use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
class DeleteShowSongCommand extends CommandBase class DeleteShowSongCommand extends CommandBase
{ {

View file

@ -21,7 +21,7 @@
namespace App\Commands; namespace App\Commands;
use App\Models\Track; use App\Models\Track;
use Gate; use Illuminate\Support\Facades\Gate;
class DeleteTrackCommand extends CommandBase class DeleteTrackCommand extends CommandBase
{ {

View file

@ -23,10 +23,10 @@ namespace App\Commands;
use App\Models\Album; use App\Models\Album;
use App\Models\Image; use App\Models\Image;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Support\Facades\Auth;
use DB; use Illuminate\Support\Facades\DB;
use Gate; use Illuminate\Support\Facades\Gate;
use Validator; use Illuminate\Support\Facades\Validator;
class EditAlbumCommand extends CommandBase class EditAlbumCommand extends CommandBase
{ {

View file

@ -22,8 +22,8 @@ namespace App\Commands;
use App\Models\PinnedPlaylist; use App\Models\PinnedPlaylist;
use App\Models\Playlist; use App\Models\Playlist;
use Auth; use Illuminate\Support\Facades\Auth;
use Validator; use Illuminate\Support\Facades\Validator;
class EditPlaylistCommand extends CommandBase class EditPlaylistCommand extends CommandBase
{ {

View file

@ -26,9 +26,9 @@ use App\Models\Playlist;
use App\Models\Track; use App\Models\Track;
use App\Models\TrackType; use App\Models\TrackType;
use App\Models\User; use App\Models\User;
use DB; use Illuminate\Support\Facades\DB;
use Gate; use Illuminate\Support\Facades\Gate;
use Notification; use Illuminate\Support\Facades\Notification;
class EditTrackCommand extends CommandBase class EditTrackCommand extends CommandBase
{ {

View file

@ -26,8 +26,8 @@ use App\Models\Track;
use App\Models\TrackFile; use App\Models\TrackFile;
use AudioCache; use AudioCache;
use FFmpegMovie; use FFmpegMovie;
use File;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use SplFileInfo; use SplFileInfo;

View file

@ -34,7 +34,7 @@ use App\Models\ResourceUser;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use Illuminate\Support\Facades\DB;
class MergeAccountsCommand extends CommandBase class MergeAccountsCommand extends CommandBase
{ {

View file

@ -28,9 +28,9 @@ use App\Models\TrackType;
use App\Models\User; use App\Models\User;
use AudioCache; use AudioCache;
use Carbon\Carbon; use Carbon\Carbon;
use Config;
use File;
use getID3; use getID3;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

View file

@ -22,8 +22,8 @@ namespace App\Commands;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\Track; use App\Models\Track;
use Auth; use Illuminate\Support\Facades\Auth;
use DB; use Illuminate\Support\Facades\DB;
class RemoveTrackFromPlaylistCommand extends CommandBase class RemoveTrackFromPlaylistCommand extends CommandBase
{ {

View file

@ -22,10 +22,10 @@ namespace App\Commands;
use App\Jobs\UpdateTagsForRenamedGenre; use App\Jobs\UpdateTagsForRenamedGenre;
use App\Models\Genre; use App\Models\Genre;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Validator;
class RenameGenreCommand extends CommandBase class RenameGenreCommand extends CommandBase
{ {

View file

@ -22,10 +22,10 @@ namespace App\Commands;
use App\Jobs\UpdateTagsForRenamedShowSong; use App\Jobs\UpdateTagsForRenamedShowSong;
use App\Models\ShowSong; use App\Models\ShowSong;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Validator;
class RenameShowSongCommand extends CommandBase class RenameShowSongCommand extends CommandBase
{ {

View file

@ -22,9 +22,9 @@ namespace App\Commands;
use App\Models\Image; use App\Models\Image;
use App\Models\User; use App\Models\User;
use DB; use Illuminate\Support\Facades\DB;
use Gate; use Illuminate\Support\Facades\Gate;
use Validator; use Illuminate\Support\Facades\Validator;
class SaveAccountSettingsCommand extends CommandBase class SaveAccountSettingsCommand extends CommandBase
{ {

View file

@ -26,9 +26,9 @@ use App\Models\Favourite;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\ResourceUser; use App\Models\ResourceUser;
use App\Models\Track; use App\Models\Track;
use Auth; use Illuminate\Support\Facades\Auth;
use DB; use Illuminate\Support\Facades\DB;
use Notification; use Illuminate\Support\Facades\Notification;
class ToggleFavouriteCommand extends CommandBase class ToggleFavouriteCommand extends CommandBase
{ {

View file

@ -22,8 +22,8 @@ namespace App\Commands;
use App\Models\Follower; use App\Models\Follower;
use App\Models\ResourceUser; use App\Models\ResourceUser;
use Auth; use Illuminate\Support\Facades\Auth;
use Notification; use Illuminate\Support\Facades\Notification;
class ToggleFollowingCommand extends CommandBase class ToggleFollowingCommand extends CommandBase
{ {

View file

@ -22,13 +22,13 @@ namespace App\Commands;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Config;
use Gate;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Request;
use Validator; use Illuminate\Support\Facades\Validator;
class UploadTrackCommand extends CommandBase class UploadTrackCommand extends CommandBase
{ {

View file

@ -23,8 +23,8 @@ namespace App\Console\Commands;
use App\Models\ShowSong; use App\Models\ShowSong;
use App\Models\Track; use App\Models\Track;
use App\Models\TrackType; use App\Models\TrackType;
use DB;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class ClassifyMLPMA extends Command class ClassifyMLPMA extends Command

View file

@ -22,8 +22,8 @@ namespace App\Console\Commands;
use App\Models\TrackFile; use App\Models\TrackFile;
use Carbon\Carbon; use Carbon\Carbon;
use File;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class ClearTrackCache extends Command class ClearTrackCache extends Command
{ {

View file

@ -21,11 +21,11 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Models\Image; use App\Models\Image;
use Config;
use DB;
use File;
use getID3; use getID3;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
class FixMLPMAImages extends Command class FixMLPMAImages extends Command

View file

@ -8,13 +8,13 @@ use App\Models\Genre;
use App\Models\Image; use App\Models\Image;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use Config;
use DB;
use File;
use getID3; use getID3;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Input; use Input;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;

View file

@ -33,9 +33,9 @@ use App\Models\ResourceUser;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Carbon\Carbon; use Carbon\Carbon;
use DB;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
class MergeAccounts extends Command class MergeAccounts extends Command
{ {

View file

@ -22,9 +22,9 @@ namespace App\Console\Commands;
use App\Models\Image; use App\Models\Image;
use App\Models\ResourceLogItem; use App\Models\ResourceLogItem;
use DB;
use Exception; use Exception;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
class MigrateOldData extends Command class MigrateOldData extends Command

View file

@ -21,8 +21,8 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Models\TrackFile; use App\Models\TrackFile;
use File;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class RebuildFilesizes extends Command class RebuildFilesizes extends Command
{ {

View file

@ -59,7 +59,7 @@ class RebuildTags extends Command
$track = Track::findOrFail($this->argument('trackId')); $track = Track::findOrFail($this->argument('trackId'));
$tracks = [$track]; $tracks = [$track];
} else { } else {
$tracks = Track::whereNotNull('published_at')->withTrashed()->orderBy('id', 'asc')->get(); $tracks = Track::whereNotNull('published_at')->withTrashed()->orderBy('id')->get();
} }
$numberOfTracks = count($tracks); $numberOfTracks = count($tracks);

View file

@ -23,9 +23,9 @@ namespace App\Console\Commands;
use App\Jobs\EncodeTrackFile; use App\Jobs\EncodeTrackFile;
use App\Models\Track; use App\Models\Track;
use App\Models\TrackFile; use App\Models\TrackFile;
use File;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\File;
class RebuildTrackCache extends Command class RebuildTrackCache extends Command
{ {

View file

@ -21,8 +21,8 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Models\ResourceLogItem; use App\Models\ResourceLogItem;
use DB;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class RefreshCache extends Command class RefreshCache extends Command
{ {

View file

@ -71,7 +71,7 @@ class SyncPoniverseAccounts extends Command
%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%'); %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%');
$usersToUpdate $usersToUpdate
->orderBy('id', 'ASC') ->orderBy('id')
->chunk(100, function ($users) use ($progress) { ->chunk(100, function ($users) use ($progress) {
/** @var User $user */ /** @var User $user */
foreach ($users as $user) { foreach ($users as $user) {

View file

@ -21,8 +21,8 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Models\TrackFile; use App\Models\TrackFile;
use File;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class VersionFiles extends Command class VersionFiles extends Command
{ {

View file

@ -20,9 +20,9 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Config; use Illuminate\Support\Facades\Config;
use Redirect; use Illuminate\Support\Facades\Redirect;
use View; use Illuminate\Support\Facades\View;
class AccountController extends Controller class AccountController extends Controller
{ {
@ -33,7 +33,7 @@ class AccountController extends Controller
public function getRegister() public function getRegister()
{ {
return redirect(config('poniverse.urls')['register']); return redirect()->to(config('poniverse.urls')['register']);
} }
public function getNotifications() public function getNotifications()

View file

@ -20,7 +20,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use View; use Illuminate\Support\Facades\View;
class AdminController extends Controller class AdminController extends Controller
{ {

View file

@ -20,13 +20,13 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App;
use App\AlbumDownloader; use App\AlbumDownloader;
use App\Models\Album; use App\Models\Album;
use App\Models\ResourceLogItem; use App\Models\ResourceLogItem;
use App\Models\Track; use App\Models\Track;
use Redirect; use Illuminate\Support\Facades\App;
use View; use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
class AlbumsController extends Controller class AlbumsController extends Controller
{ {

View file

@ -22,7 +22,7 @@ namespace App\Http\Controllers\Api\Mobile;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Track; use App\Models\Track;
use Response; use Illuminate\Support\Facades\Response;
class TracksController extends Controller class TracksController extends Controller
{ {
@ -44,7 +44,7 @@ class TracksController extends Controller
'tracks' => $tracks->toArray(), 'tracks' => $tracks->toArray(),
]; ];
return Response::json($json, 200); return response()->json($json, 200);
} }
public function popular() public function popular()
@ -56,6 +56,6 @@ class TracksController extends Controller
'tracks' => $tracks->toArray(), 'tracks' => $tracks->toArray(),
]; ];
return Response::json($json, 200); return response()->json($json, 200);
} }
} }

View file

@ -24,7 +24,7 @@ use App\Commands\UploadTrackCommand;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\Image; use App\Models\Image;
use App\Models\Track; use App\Models\Track;
use Response; use Illuminate\Support\Facades\Response;
class TracksController extends ApiControllerBase class TracksController extends ApiControllerBase
{ {
@ -60,9 +60,9 @@ class TracksController extends ApiControllerBase
$this->authorize('edit', $track); $this->authorize('edit', $track);
if ($track->status === Track::STATUS_PROCESSING) { if ($track->status === Track::STATUS_PROCESSING) {
return Response::json(['message' => 'Processing...'], 202); return response()->json(['message' => 'Processing...'], 202);
} elseif ($track->status === Track::STATUS_COMPLETE) { } elseif ($track->status === Track::STATUS_COMPLETE) {
return Response::json([ return response()->json([
'message' => $track->published_at 'message' => $track->published_at
? 'Processing complete! The track is live at the track_url. The artist can edit the track by visiting its edit_url.' ? 'Processing complete! The track is live at the track_url. The artist can edit the track by visiting its edit_url.'
: 'Processing complete! The artist must publish the track by visiting its edit_url.', : 'Processing complete! The artist must publish the track by visiting its edit_url.',
@ -71,7 +71,7 @@ class TracksController extends ApiControllerBase
], 201); ], 201);
} else { } else {
// something went wrong // something went wrong
return Response::json(['error' => 'Processing failed! Please contact logic@pony.fm to figure out what went wrong.'], 500); return response()->json(['error' => 'Processing failed! Please contact logic@pony.fm to figure out what went wrong.'], 500);
} }
} }
@ -92,10 +92,10 @@ class TracksController extends ApiControllerBase
->where('id', $id)->first(); ->where('id', $id)->first();
if (! $track) { if (! $track) {
return Response::json(['message' => 'Track not found.'], 404); return response()->json(['message' => 'Track not found.'], 404);
} }
return Response::json(self::trackToJson($track, false, true), 200); return response()->json(self::trackToJson($track, false, true), 200);
} }
/** /**
@ -114,10 +114,10 @@ class TracksController extends ApiControllerBase
->where('hash', $hash)->first(); ->where('hash', $hash)->first();
if (! $track) { if (! $track) {
return Response::json(['message' => 'Track not found.'], 403); return response()->json(['message' => 'Track not found.'], 403);
} }
return Response::json(self::trackToJson($track, true, false), 200); return response()->json(self::trackToJson($track, true, false), 200);
} }
/** /**

View file

@ -24,10 +24,10 @@ use App\Commands\SaveAccountSettingsCommand;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\Image; use App\Models\Image;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Http\Request;
use Gate; use Illuminate\Support\Facades\Auth;
use Request; use Illuminate\Support\Facades\Gate;
use Response; use Illuminate\Support\Facades\Response;
class AccountController extends ApiControllerBase class AccountController extends ApiControllerBase
{ {
@ -35,23 +35,23 @@ class AccountController extends ApiControllerBase
{ {
$this->authorize('edit', $user); $this->authorize('edit', $user);
return Response::json([ return response()->json([
'user' => $user->toArray(), 'user' => $user->toArray(),
]); ]);
} }
public function getCurrentUser() public function getCurrentUser(Request $request)
{ {
$current_user = Auth::user(); $current_user = $request->user();
if ($current_user != null) { if ($current_user != null) {
$user = User::where('id', $current_user->id)->whereNull('disabled_at')->first(); $user = User::where('id', $current_user->id)->whereNull('disabled_at')->first();
if ($user == null) { if ($user == null) {
return Response::json(['error' => 'You are not logged in'], 404); return response()->json(['error' => 'You are not logged in'], 404);
} }
return Response::json([ return response()->json([
'id' => $user->id, 'id' => $user->id,
'name' => $user->display_name, 'name' => $user->display_name,
'slug' => $user->slug, 'slug' => $user->slug,
@ -64,14 +64,14 @@ class AccountController extends ApiControllerBase
'created_at' => $user->created_at, 'created_at' => $user->created_at,
], 200); ], 200);
} else { } else {
return Response::json(['error' => 'You are not logged in'], 404); return response()->json(['error' => 'You are not logged in'], 404);
} }
} }
public function getSettings($slug) public function getSettings(Request $request, $slug)
{ {
$user = null; $user = null;
$current_user = Auth::user(); $current_user = $request->user();
if ($current_user != null) { if ($current_user != null) {
if ($slug == $current_user->slug) { if ($slug == $current_user->slug) {
@ -81,15 +81,15 @@ class AccountController extends ApiControllerBase
} }
if ($user == null) { if ($user == null) {
return Response::json(['error' => 'User does not exist'], 404); return response()->json(['error' => 'User does not exist'], 404);
} }
if (Gate::denies('edit', $user)) { if (Gate::denies('edit', $user)) {
return Response::json(['error' => 'You cannot do that. So stop trying!'], 403); return response()->json(['error' => 'You cannot do that. So stop trying!'], 403);
} }
} }
return Response::json([ return response()->json([
'id' => $user->id, 'id' => $user->id,
'bio' => $user->bio, 'bio' => $user->bio,
'can_see_explicit_content' => $user->can_see_explicit_content == 1, 'can_see_explicit_content' => $user->can_see_explicit_content == 1,
@ -104,8 +104,8 @@ class AccountController extends ApiControllerBase
], 200); ], 200);
} }
public function postSave(User $user) public function postSave(Request $request, User $user)
{ {
return $this->execute(new SaveAccountSettingsCommand(Request::all(), $user)); return $this->execute(new SaveAccountSettingsCommand($request->all(), $user));
} }
} }

View file

@ -29,22 +29,22 @@ use App\Models\Image;
use App\Models\ResourceLogItem; use App\Models\ResourceLogItem;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Auth;
use Gate;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Response;
class AlbumsController extends ApiControllerBase class AlbumsController extends ApiControllerBase
{ {
public function postCreate() public function postCreate(Request $request)
{ {
return $this->execute(new CreateAlbumCommand(Request::all())); return $this->execute(new CreateAlbumCommand($request->all()));
} }
public function postEdit($id) public function postEdit(Request $request, $id)
{ {
return $this->execute(new EditAlbumCommand($id, Request::all())); return $this->execute(new EditAlbumCommand($id, $request->all()));
} }
public function postDelete($id) public function postDelete($id)
@ -52,7 +52,7 @@ class AlbumsController extends ApiControllerBase
return $this->execute(new DeleteAlbumCommand($id)); return $this->execute(new DeleteAlbumCommand($id));
} }
public function getShow($id) public function getShow(Request $request, $id)
{ {
$album = Album::with([ $album = Album::with([
'tracks' => function ($query) { 'tracks' => function ($query) {
@ -75,7 +75,7 @@ class AlbumsController extends ApiControllerBase
abort(404); abort(404);
} }
if (Request::get('log')) { if ($request->get('log')) {
ResourceLogItem::logItem('album', $id, ResourceLogItem::VIEW); ResourceLogItem::logItem('album', $id, ResourceLogItem::VIEW);
$album->view_count++; $album->view_count++;
} }
@ -85,7 +85,7 @@ class AlbumsController extends ApiControllerBase
unset($returned_album['formats']); unset($returned_album['formats']);
} }
return Response::json([ return response()->json([
'album' => $returned_album, 'album' => $returned_album,
], 200); ], 200);
} }
@ -114,14 +114,14 @@ class AlbumsController extends ApiControllerBase
$url = null; $url = null;
} }
return Response::json(['url' => $url], 200); return response()->json(['url' => $url], 200);
} }
public function getIndex() public function getIndex(Request $request)
{ {
$page = 1; $page = 1;
if (Request::has('page')) { if ($request->has('page')) {
$page = Request::get('page'); $page = $request->get('page');
} }
$query = Album::summary() $query = Album::summary()
@ -134,7 +134,7 @@ class AlbumsController extends ApiControllerBase
$perPage = 40; $perPage = 40;
$query $query
->orderBy('title', 'asc') ->orderBy('title')
->skip(($page - 1) * $perPage) ->skip(($page - 1) * $perPage)
->take($perPage); ->take($perPage);
$albums = []; $albums = [];
@ -143,7 +143,7 @@ class AlbumsController extends ApiControllerBase
$albums[] = Album::mapPublicAlbumSummary($album); $albums[] = Album::mapPublicAlbumSummary($album);
} }
return Response::json( return response()->json(
['albums' => $albums, 'current_page' => $page, 'total_pages' => ceil($count / $perPage)], ['albums' => $albums, 'current_page' => $page, 'total_pages' => ceil($count / $perPage)],
200 200
); );
@ -156,7 +156,7 @@ class AlbumsController extends ApiControllerBase
$query = Album::summary() $query = Album::summary()
->with('cover', 'user.avatar') ->with('cover', 'user.avatar')
->where('user_id', $user->id) ->where('user_id', $user->id)
->orderBy('created_at', 'desc')->get(); ->orderByDesc('created_at')->get();
$albums = []; $albums = [];
foreach ($query as $album) { foreach ($query as $album) {
@ -172,17 +172,17 @@ class AlbumsController extends ApiControllerBase
]; ];
} }
return Response::json($albums, 200); return response()->json($albums, 200);
} }
public function getEdit($id) public function getEdit(Request $request, $id)
{ {
$album = Album::with('tracks')->find($id); $album = Album::with('tracks')->find($id);
if (! $album) { if (! $album) {
return $this->notFound('Album '.$id.' not found!'); return $this->notFound('Album '.$id.' not found!');
} }
if (Gate::denies('edit', Auth::user())) { if (Gate::denies('edit', $request->user())) {
return $this->notAuthorized(); return $this->notAuthorized();
} }
@ -194,7 +194,7 @@ class AlbumsController extends ApiControllerBase
]; ];
} }
return Response::json([ return response()->json([
'id' => $album->id, 'id' => $album->id,
'title' => $album->title, 'title' => $album->title,
'user_id' => $album->user_id, 'user_id' => $album->user_id,

View file

@ -24,8 +24,8 @@ use App\Commands\CreateAnnouncementCommand;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Announcement; use App\Models\Announcement;
use Carbon\Carbon; use Carbon\Carbon;
use Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\Response;
class AnnouncementsController extends Controller class AnnouncementsController extends Controller
{ {
@ -37,11 +37,11 @@ class AnnouncementsController extends Controller
->whereNotNull('end_time') ->whereNotNull('end_time')
->where('start_time', '<', $currentDate) ->where('start_time', '<', $currentDate)
->where('end_time', '>', $currentDate) ->where('end_time', '>', $currentDate)
->orderBy('start_time', 'desc'); ->orderByDesc('start_time');
$announcement = $query->first(); $announcement = $query->first();
return Response::json( return response()->json(
['announcement' => $announcement], ['announcement' => $announcement],
200 200
); );
@ -51,10 +51,10 @@ class AnnouncementsController extends Controller
{ {
$this->authorize('access-admin-area'); $this->authorize('access-admin-area');
$announcements = Announcement::orderBy('start_time', 'desc') $announcements = Announcement::orderByDesc('start_time')
->get(); ->get();
return Response::json([ return response()->json([
'announcements' => $announcements->toArray(), 'announcements' => $announcements->toArray(),
], 200); ], 200);
} }
@ -64,19 +64,19 @@ class AnnouncementsController extends Controller
$this->authorize('access-admin-area'); $this->authorize('access-admin-area');
$query = Announcement::where('id', '=', $genreId) $query = Announcement::where('id', '=', $genreId)
->orderBy('start_time', 'desc'); ->orderByDesc('start_time');
$announcement = $query->first(); $announcement = $query->first();
return Response::json( return response()->json(
['announcement' => $announcement], ['announcement' => $announcement],
200 200
); );
} }
public function postCreate() public function postCreate(Request $request)
{ {
$command = new CreateAnnouncementCommand(Request::get('name')); $command = new CreateAnnouncementCommand($request->get('name'));
return $this->execute($command); return $this->execute($command);
} }

View file

@ -20,7 +20,6 @@
namespace App\Http\Controllers\Api\Web; namespace App\Http\Controllers\Api\Web;
use App;
use App\Commands\CreateUserCommand; use App\Commands\CreateUserCommand;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\Album; use App\Models\Album;
@ -31,10 +30,11 @@ use App\Models\Image;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use ColorThief\ColorThief; use ColorThief\ColorThief;
use Gate;
use Helpers; use Helpers;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Response;
class ArtistsController extends ApiControllerBase class ArtistsController extends ApiControllerBase
{ {
@ -78,7 +78,7 @@ class ArtistsController extends ApiControllerBase
} }
} }
return Response::json([ return response()->json([
'tracks' => $tracks, 'tracks' => $tracks,
'albums' => $albums, 'albums' => $albums,
], 200); ], 200);
@ -112,7 +112,7 @@ class ArtistsController extends ApiControllerBase
$query = Album::summary() $query = Album::summary()
->with('user') ->with('user')
->orderBy('created_at', 'desc') ->orderByDesc('created_at')
->where('track_count', '>', 0) ->where('track_count', '>', 0)
->whereUserId($user->id); ->whereUserId($user->id);
@ -122,7 +122,7 @@ class ArtistsController extends ApiControllerBase
$albums[] = Album::mapPublicAlbumSummary($album); $albums[] = Album::mapPublicAlbumSummary($album);
} }
return Response::json(['singles' => $singles, 'albumTracks' => $tracks, 'albums' => $albums], 200); return response()->json(['singles' => $singles, 'albumTracks' => $tracks, 'albums' => $albums], 200);
} }
public function getShow($slug) public function getShow($slug)
@ -148,7 +148,7 @@ class ArtistsController extends ApiControllerBase
->userDetails() ->userDetails()
->whereUserId($user->id) ->whereUserId($user->id)
->whereNotNull('published_at') ->whereNotNull('published_at')
->orderBy('created_at', 'desc') ->orderByDesc('created_at')
->take(20); ->take(20);
$latestTracks = []; $latestTracks = [];
@ -178,7 +178,7 @@ class ArtistsController extends ApiControllerBase
$followers = Follower::where('artist_id', $user->id) $followers = Follower::where('artist_id', $user->id)
->count(); ->count();
return Response::json([ return response()->json([
'artist' => [ 'artist' => [
'id' => $user->id, 'id' => $user->id,
'name' => $user->display_name, 'name' => $user->display_name,
@ -206,11 +206,11 @@ class ArtistsController extends ApiControllerBase
], 200); ], 200);
} }
public function getIndex() public function getIndex(Request $request)
{ {
$page = 1; $page = 1;
if (Request::has('page')) { if ($request->has('page')) {
$page = Request::get('page'); $page = $request->get('page');
} }
$query = User::where('track_count', '>', 0); $query = User::where('track_count', '>', 0);
@ -218,7 +218,7 @@ class ArtistsController extends ApiControllerBase
// The query results are ordered after they're counted // The query results are ordered after they're counted
// due to Postgres's behaviour when combining those two operations. // due to Postgres's behaviour when combining those two operations.
$query->orderBy('display_name', 'asc'); $query->orderBy('display_name');
$perPage = 40; $perPage = 40;
$query->skip(($page - 1) * $perPage)->take($perPage); $query->skip(($page - 1) * $perPage)->take($perPage);
$users = []; $users = [];
@ -227,15 +227,15 @@ class ArtistsController extends ApiControllerBase
$users[] = User::mapPublicUserSummary($user); $users[] = User::mapPublicUserSummary($user);
} }
return Response::json( return response()->json(
['artists' => $users, 'current_page' => $page, 'total_pages' => ceil($count / $perPage)], ['artists' => $users, 'current_page' => $page, 'total_pages' => ceil($count / $perPage)],
200 200
); );
} }
public function postIndex() public function postIndex(Request $request)
{ {
$name = Request::json('username'); $name = $request->json('username');
return $this->execute(new CreateUserCommand($name, $name, null, true)); return $this->execute(new CreateUserCommand($name, $name, null, true));
} }

View file

@ -20,18 +20,18 @@
namespace App\Http\Controllers\Api\Web; namespace App\Http\Controllers\Api\Web;
use App;
use App\Commands\CreateCommentCommand; use App\Commands\CreateCommentCommand;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\Comment; use App\Models\Comment;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Response;
class CommentsController extends ApiControllerBase class CommentsController extends ApiControllerBase
{ {
public function postCreate($type, $id) public function postCreate(Request $request, $type, $id)
{ {
return $this->execute(new CreateCommentCommand($type, $id, Request::all())); return $this->execute(new CreateCommentCommand($type, $id, $request->all()));
} }
public function getIndex($type, $id) public function getIndex($type, $id)
@ -56,13 +56,13 @@ class CommentsController extends ApiControllerBase
} }
} }
$query = Comment::where($column, '=', $id)->orderBy('created_at', 'desc')->with('user'); $query = Comment::where($column, '=', $id)->orderByDesc('created_at')->with('user');
$comments = []; $comments = [];
foreach ($query->get() as $comment) { foreach ($query->get() as $comment) {
$comments[] = Comment::mapPublic($comment); $comments[] = Comment::mapPublic($comment);
} }
return Response::json(['list' => $comments, 'count' => count($comments)]); return response()->json(['list' => $comments, 'count' => count($comments)]);
} }
} }

View file

@ -22,12 +22,13 @@ namespace App\Http\Controllers\Api\Web;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\Track; use App\Models\Track;
use Auth; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Response;
class DashboardController extends ApiControllerBase class DashboardController extends ApiControllerBase
{ {
public function getIndex() public function getIndex(Request $request)
{ {
$recentQuery = Track::summary() $recentQuery = Track::summary()
->with(['genre', 'user', 'cover', 'user.avatar']) ->with(['genre', 'user', 'cover', 'user.avatar'])
@ -36,7 +37,7 @@ class DashboardController extends ApiControllerBase
->userDetails() ->userDetails()
->explicitFilter() ->explicitFilter()
->published() ->published()
->orderBy('published_at', 'desc') ->orderByDesc('published_at')
->take(30); ->take(30);
$recentQuery->whereHas('user', function ($q) { $recentQuery->whereHas('user', function ($q) {
@ -49,9 +50,9 @@ class DashboardController extends ApiControllerBase
$recentTracks[] = Track::mapPublicTrackSummary($track); $recentTracks[] = Track::mapPublicTrackSummary($track);
} }
return Response::json([ return response()->json([
'recent_tracks' => $recentTracks, 'recent_tracks' => $recentTracks,
'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content), 'popular_tracks' => Track::popular(30, $request->user() && $request->user()->can_see_explicit_content),
], 200); ], 200);
} }
} }

View file

@ -26,21 +26,21 @@ use App\Models\Album;
use App\Models\Favourite; use App\Models\Favourite;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\Track; use App\Models\Track;
use Auth; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Auth;
use Response; use Illuminate\Support\Facades\Response;
class FavouritesController extends ApiControllerBase class FavouritesController extends ApiControllerBase
{ {
public function postToggle() public function postToggle(Request $request)
{ {
return $this->execute(new ToggleFavouriteCommand(Request::get('type'), Request::get('id'))); return $this->execute(new ToggleFavouriteCommand($request->get('type'), $request->get('id')));
} }
public function getTracks() public function getTracks(Request $request)
{ {
$query = Favourite $query = Favourite
::whereUserId(Auth::user()->id) ::whereUserId($request->user()->id)
->whereNotNull('track_id') ->whereNotNull('track_id')
->with([ ->with([
'track' => function ($query) { 'track' => function ($query) {
@ -65,13 +65,13 @@ class FavouritesController extends ApiControllerBase
$tracks[] = Track::mapPublicTrackSummary($fav->track); $tracks[] = Track::mapPublicTrackSummary($fav->track);
} }
return Response::json(['tracks' => $tracks], 200); return response()->json(['tracks' => $tracks], 200);
} }
public function getAlbums() public function getAlbums(Request $request)
{ {
$query = Favourite $query = Favourite
::whereUserId(Auth::user()->id) ::whereUserId($request->user()->id)
->whereNotNull('album_id') ->whereNotNull('album_id')
->with([ ->with([
'album' => function ($query) { 'album' => function ($query) {
@ -92,13 +92,13 @@ class FavouritesController extends ApiControllerBase
$albums[] = Album::mapPublicAlbumSummary($fav->album); $albums[] = Album::mapPublicAlbumSummary($fav->album);
} }
return Response::json(['albums' => $albums], 200); return response()->json(['albums' => $albums], 200);
} }
public function getPlaylist() public function getPlaylist(Request $request)
{ {
$query = Favourite $query = Favourite
::whereUserId(Auth::user()->id) ::whereUserId($request->user()->id)
->whereNotNull('playlist_id') ->whereNotNull('playlist_id')
->with([ ->with([
'playlist' => function ($query) { 'playlist' => function ($query) {
@ -120,6 +120,6 @@ class FavouritesController extends ApiControllerBase
$playlists[] = Playlist::mapPublicPlaylistSummary($fav->playlist); $playlists[] = Playlist::mapPublicPlaylistSummary($fav->playlist);
} }
return Response::json(['playlists' => $playlists], 200); return response()->json(['playlists' => $playlists], 200);
} }
} }

View file

@ -22,12 +22,12 @@ namespace App\Http\Controllers\Api\Web;
use App\Commands\ToggleFollowingCommand; use App\Commands\ToggleFollowingCommand;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
class FollowController extends ApiControllerBase class FollowController extends ApiControllerBase
{ {
public function postToggle() public function postToggle(Request $request)
{ {
return $this->execute(new ToggleFollowingCommand(Request::get('type'), Request::get('id'))); return $this->execute(new ToggleFollowingCommand($request->get('type'), $request->get('id')));
} }
} }

View file

@ -25,8 +25,8 @@ use App\Commands\DeleteGenreCommand;
use App\Commands\RenameGenreCommand; use App\Commands\RenameGenreCommand;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\Genre; use App\Models\Genre;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\Response;
class GenresController extends ApiControllerBase class GenresController extends ApiControllerBase
{ {
@ -37,31 +37,31 @@ class GenresController extends ApiControllerBase
$genres = Genre::with(['trackCountRelation' => function ($query) { $genres = Genre::with(['trackCountRelation' => function ($query) {
$query->withTrashed(); $query->withTrashed();
}]) }])
->orderBy('name', 'asc') ->orderBy('name')
->get(); ->get();
return Response::json([ return response()->json([
'genres' => $genres->toArray(), 'genres' => $genres->toArray(),
], 200); ], 200);
} }
public function postCreate() public function postCreate(Request $request)
{ {
$command = new CreateGenreCommand(Request::get('name')); $command = new CreateGenreCommand($request->get('name'));
return $this->execute($command); return $this->execute($command);
} }
public function putRename($genreId) public function putRename(Request $request, $genreId)
{ {
$command = new RenameGenreCommand($genreId, Request::get('name')); $command = new RenameGenreCommand($genreId, $request->get('name'));
return $this->execute($command); return $this->execute($command);
} }
public function deleteGenre($genreId) public function deleteGenre(Request $request, $genreId)
{ {
$command = new DeleteGenreCommand($genreId, Request::get('destination_genre_id')); $command = new DeleteGenreCommand($genreId, $request->get('destination_genre_id'));
return $this->execute($command); return $this->execute($command);
} }

View file

@ -23,8 +23,8 @@ namespace App\Http\Controllers\Api\Web;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\Image; use App\Models\Image;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Support\Facades\Auth;
use Response; use Illuminate\Support\Facades\Response;
class ImagesController extends ApiControllerBase class ImagesController extends ApiControllerBase
{ {
@ -48,6 +48,6 @@ class ImagesController extends ApiControllerBase
]; ];
} }
return Response::json($images, 200); return response()->json($images, 200);
} }
} }

View file

@ -25,8 +25,8 @@ use App\Models\Notification;
use App\Models\Subscription; use App\Models\Subscription;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Auth; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\Auth;
use Minishlink\WebPush\WebPush; use Minishlink\WebPush\WebPush;
class NotificationsController extends ApiControllerBase class NotificationsController extends ApiControllerBase
@ -36,9 +36,9 @@ class NotificationsController extends ApiControllerBase
* *
* @return array * @return array
*/ */
public function getNotifications() public function getNotifications(Request $request)
{ {
$notifications = Notification::forUser(Auth::user()) $notifications = Notification::forUser($request->user())
->take(20) ->take(20)
->get(); ->get();
@ -54,10 +54,10 @@ class NotificationsController extends ApiControllerBase
* *
* @return array * @return array
*/ */
public function putMarkAsRead() public function putMarkAsRead(Request $request)
{ {
$notificationIds = Request::json('notification_ids'); $notificationIds = $request->json('notification_ids');
$numberOfUpdatedRows = Auth::user() $numberOfUpdatedRows = $request->user()
->notifications() ->notifications()
->whereIn('id', $notificationIds) ->whereIn('id', $notificationIds)
->update(['is_read' => true]); ->update(['is_read' => true]);
@ -72,17 +72,17 @@ class NotificationsController extends ApiControllerBase
* *
* @return string * @return string
*/ */
public function postSubscribe() public function postSubscribe(Request $request)
{ {
$input = json_decode(Request::json('subscription')); $input = json_decode($request->json('subscription'));
if ($input != 'null') { if ($input != 'null') {
$existing = Subscription::where('endpoint', '=', $input->endpoint) $existing = Subscription::where('endpoint', '=', $input->endpoint)
->where('user_id', '=', Auth::user()->id) ->where('user_id', '=', $request->user()->id)
->first(); ->first();
if ($existing === null) { if ($existing === null) {
$subscription = Subscription::create([ $subscription = Subscription::create([
'user_id' => Auth::user()->id, 'user_id' => $request->user()->id,
'endpoint' => $input->endpoint, 'endpoint' => $input->endpoint,
'p256dh' => $input->keys->p256dh, 'p256dh' => $input->keys->p256dh,
'auth' => $input->keys->auth, 'auth' => $input->keys->auth,
@ -102,12 +102,12 @@ class NotificationsController extends ApiControllerBase
* *
* @return string * @return string
*/ */
public function postUnsubscribe() public function postUnsubscribe(Request $request)
{ {
$input = json_decode(Request::json('subscription')); $input = json_decode($request->json('subscription'));
$existing = Subscription::where('endpoint', '=', $input->endpoint) $existing = Subscription::where('endpoint', '=', $input->endpoint)
->where('user_id', '=', Auth::user()->id) ->where('user_id', '=', $request->user()->id)
->delete(); ->delete();
return ['result' => 'success']; return ['result' => 'success'];

View file

@ -31,21 +31,21 @@ use App\Models\Playlist;
use App\Models\ResourceLogItem; use App\Models\ResourceLogItem;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Auth;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Response;
class PlaylistsController extends ApiControllerBase class PlaylistsController extends ApiControllerBase
{ {
public function postCreate() public function postCreate(Request $request)
{ {
return $this->execute(new CreatePlaylistCommand(Request::all())); return $this->execute(new CreatePlaylistCommand($request->all()));
} }
public function postEdit($id) public function postEdit(Request $request, $id)
{ {
return $this->execute(new EditPlaylistCommand($id, Request::all())); return $this->execute(new EditPlaylistCommand($id, $request->all()));
} }
public function postDelete($id) public function postDelete($id)
@ -53,19 +53,19 @@ class PlaylistsController extends ApiControllerBase
return $this->execute(new DeletePlaylistCommand($id)); return $this->execute(new DeletePlaylistCommand($id));
} }
public function postAddTrack($id) public function postAddTrack(Request $request, $id)
{ {
return $this->execute(new AddTrackToPlaylistCommand($id, Request::get('track_id'))); return $this->execute(new AddTrackToPlaylistCommand($id, $request->get('track_id')));
} }
public function postRemoveTrack($id) public function postRemoveTrack(Request $request, $id)
{ {
return $this->execute(new RemoveTrackFromPlaylistCommand($id, Request::get('track_id'))); return $this->execute(new RemoveTrackFromPlaylistCommand($id, $request->get('track_id')));
} }
public function getIndex() public function getIndex(Request $request)
{ {
$page = Request::has('page') ? Request::get('page') : 1; $page = $request->has('page') ? $request->get('page') : 1;
$query = Playlist::summary() $query = Playlist::summary()
->with( ->with(
@ -94,14 +94,14 @@ class PlaylistsController extends ApiControllerBase
$playlists[] = Playlist::mapPublicPlaylistSummary($playlist); $playlists[] = Playlist::mapPublicPlaylistSummary($playlist);
} }
return Response::json([ return response()->json([
'playlists' => $playlists, 'playlists' => $playlists,
'current_page' => $page, 'current_page' => $page,
'total_pages' => ceil($count / $perPage), 'total_pages' => ceil($count / $perPage),
], 200); ], 200);
} }
public function getShow($id) public function getShow(Request $request, $id)
{ {
$playlist = Playlist::with([ $playlist = Playlist::with([
'tracks.user', 'tracks.user',
@ -115,19 +115,19 @@ class PlaylistsController extends ApiControllerBase
'comments', 'comments',
'comments.user', 'comments.user',
])->userDetails()->find($id); ])->userDetails()->find($id);
if (! $playlist || ! $playlist->canView(Auth::user())) { if (! $playlist || ! $playlist->canView($request->user())) {
abort('404'); abort('404');
} }
if (Request::get('log')) { if ($request->get('log')) {
ResourceLogItem::logItem('playlist', $id, ResourceLogItem::VIEW); ResourceLogItem::logItem('playlist', $id, ResourceLogItem::VIEW);
$playlist->view_count++; $playlist->view_count++;
} }
return Response::json(Playlist::mapPublicPlaylistShow($playlist), 200); return response()->json(Playlist::mapPublicPlaylistShow($playlist), 200);
} }
public function getCachedPlaylist($id, $format) public function getCachedPlaylist(Request $request, $id, $format)
{ {
// Validation // Validation
try { try {
@ -137,7 +137,7 @@ class PlaylistsController extends ApiControllerBase
return $this->notFound('Playlist not found!'); return $this->notFound('Playlist not found!');
} }
if ((! $playlist->is_public && ! Auth::check()) || (! $playlist->is_public && ($playlist->user_id !== Auth::user()->id))) { if ((! $playlist->is_public && ! $request->user()) || (! $playlist->is_public && ($playlist->user_id !== $request->user()->id))) {
return $this->notFound('Playlist not found!'); return $this->notFound('Playlist not found!');
} }
@ -155,10 +155,10 @@ class PlaylistsController extends ApiControllerBase
$url = null; $url = null;
} }
return Response::json(['url' => $url], 200); return response()->json(['url' => $url], 200);
} }
public function getPinned() public function getPinned(Request $request)
{ {
$query = Playlist $query = Playlist
::userDetails() ::userDetails()
@ -166,8 +166,8 @@ class PlaylistsController extends ApiControllerBase
->join('pinned_playlists', function ($join) { ->join('pinned_playlists', function ($join) {
$join->on('playlist_id', '=', 'playlists.id'); $join->on('playlist_id', '=', 'playlists.id');
}) })
->where('pinned_playlists.user_id', '=', Auth::user()->id) ->where('pinned_playlists.user_id', '=', $request->user()->id)
->orderBy('title', 'asc') ->orderBy('title')
->select('playlists.*') ->select('playlists.*')
->get(); ->get();
@ -179,15 +179,15 @@ class PlaylistsController extends ApiControllerBase
$playlists[] = $mapped; $playlists[] = $mapped;
} }
return Response::json($playlists, 200); return response()->json($playlists, 200);
} }
public function getOwned(User $user) public function getOwned(Request $request, User $user)
{ {
$query = Playlist::summary() $query = Playlist::summary()
->with('pins', 'tracks', 'tracks.cover') ->with('pins', 'tracks', 'tracks.cover')
->where('user_id', $user->id) ->where('user_id', $user->id)
->orderBy('title', 'asc') ->orderBy('title')
->get(); ->get();
$playlists = []; $playlists = [];
@ -203,13 +203,13 @@ class PlaylistsController extends ApiControllerBase
'small' => $playlist->getCoverUrl(Image::SMALL), 'small' => $playlist->getCoverUrl(Image::SMALL),
'normal' => $playlist->getCoverUrl(Image::NORMAL), 'normal' => $playlist->getCoverUrl(Image::NORMAL),
], ],
'is_pinned' => $playlist->hasPinFor(Auth::user()->id), 'is_pinned' => $playlist->hasPinFor($request->user()->id),
'is_public' => $playlist->is_public == 1, 'is_public' => $playlist->is_public == 1,
'track_ids' => $playlist->tracks->pluck('id'), 'track_ids' => $playlist->tracks->pluck('id'),
]; ];
} }
return Response::json($playlists, 200); return response()->json($playlists, 200);
} }
/** /**

View file

@ -23,16 +23,16 @@ namespace App\Http\Controllers\Api\Web;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Library\Search; use App\Library\Search;
use Elasticsearch; use Elasticsearch;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\Response;
class SearchController extends ApiControllerBase class SearchController extends ApiControllerBase
{ {
public function getSearch(Search $search) public function getSearch(Request $request, Search $search)
{ {
$results = $search->searchAllContent(Request::query('query')); $results = $search->searchAllContent($request->query('query'));
return Response::json([ return response()->json([
'results' => $results, 'results' => $results,
], 200); ], 200);
} }

View file

@ -25,8 +25,8 @@ use App\Commands\DeleteShowSongCommand;
use App\Commands\RenameShowSongCommand; use App\Commands\RenameShowSongCommand;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\ShowSong; use App\Models\ShowSong;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\Response;
class ShowSongsController extends ApiControllerBase class ShowSongsController extends ApiControllerBase
{ {
@ -37,32 +37,32 @@ class ShowSongsController extends ApiControllerBase
$songs = ShowSong::with(['trackCountRelation' => function ($query) { $songs = ShowSong::with(['trackCountRelation' => function ($query) {
$query->withTrashed(); $query->withTrashed();
}]) }])
->orderBy('title', 'asc') ->orderBy('title')
->select('id', 'title', 'slug') ->select('id', 'title', 'slug')
->get(); ->get();
return Response::json([ return response()->json([
'showsongs' => $songs->toArray(), 'showsongs' => $songs->toArray(),
], 200); ], 200);
} }
public function postCreate() public function postCreate(Request $request)
{ {
$command = new CreateShowSongCommand(Request::get('title')); $command = new CreateShowSongCommand($request->get('title'));
return $this->execute($command); return $this->execute($command);
} }
public function putRename($songId) public function putRename(Request $request, $songId)
{ {
$command = new RenameShowSongCommand($songId, Request::get('title')); $command = new RenameShowSongCommand($songId, $request->get('title'));
return $this->execute($command); return $this->execute($command);
} }
public function deleteSong($songId) public function deleteSong(Request $request, $songId)
{ {
$command = new DeleteShowSongCommand($songId, Request::get('destination_song_id')); $command = new DeleteShowSongCommand($songId, $request->get('destination_song_id'));
return $this->execute($command); return $this->execute($command);
} }

View file

@ -23,13 +23,14 @@ namespace App\Http\Controllers\Api\Web;
use App\Http\Controllers\ApiControllerBase; use App\Http\Controllers\ApiControllerBase;
use App\Models\ResourceLogItem; use App\Models\ResourceLogItem;
use App\Models\Track; use App\Models\Track;
use Auth;
use Cache;
use Carbon\Carbon; use Carbon\Carbon;
use DB;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Response;
class StatsController extends ApiControllerBase class StatsController extends ApiControllerBase
{ {
@ -101,13 +102,13 @@ class StatsController extends ApiControllerBase
} }
if ($hourly) { if ($hourly) {
return Response::json(['playStats' => $output, 'type' => 'Hourly'], 200); return response()->json(['playStats' => $output, 'type' => 'Hourly'], 200);
} else { } else {
return Response::json(['playStats' => $output, 'type' => 'Daily'], 200); return response()->json(['playStats' => $output, 'type' => 'Daily'], 200);
} }
} }
public function getTrackStats($id) public function getTrackStats(Request $request, $id)
{ {
$cachedOutput = Cache::remember('track_stats'.$id, 300, function () use ($id) { $cachedOutput = Cache::remember('track_stats'.$id, 300, function () use ($id) {
try { try {
@ -117,7 +118,7 @@ class StatsController extends ApiControllerBase
} }
// Do we have permission to view this track? // Do we have permission to view this track?
if (! $track->canView(Auth::user())) { if (! $track->canView($request->user())) {
return $this->notFound('Track not found!'); return $this->notFound('Track not found!');
} }

View file

@ -25,13 +25,13 @@ use App\Models\Genre;
use App\Models\License; use App\Models\License;
use App\Models\ShowSong; use App\Models\ShowSong;
use App\Models\TrackType; use App\Models\TrackType;
use DB; use Illuminate\Support\Facades\DB;
class TaxonomiesController extends ApiControllerBase class TaxonomiesController extends ApiControllerBase
{ {
public function getAll() public function getAll()
{ {
return \Response::json([ return response()->json([
'licenses' => License::all()->toArray(), 'licenses' => License::all()->toArray(),
'genres' => Genre::with('trackCountRelation') 'genres' => Genre::with('trackCountRelation')
->orderBy('name') ->orderBy('name')

View file

@ -32,11 +32,11 @@ use App\Models\Track;
use App\Models\TrackFile; use App\Models\TrackFile;
use App\Models\TrackType; use App\Models\TrackType;
use App\Models\User; use App\Models\User;
use Auth;
use File;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Facades\Request; use Illuminate\Http\Request;
use Response; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Response;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
class TracksController extends ApiControllerBase class TracksController extends ApiControllerBase
@ -54,12 +54,12 @@ class TracksController extends ApiControllerBase
$this->authorize('edit', $track); $this->authorize('edit', $track);
if ($track->status === Track::STATUS_PROCESSING) { if ($track->status === Track::STATUS_PROCESSING) {
return Response::json(['message' => 'Processing...'], 202); return response()->json(['message' => 'Processing...'], 202);
} elseif ($track->status === Track::STATUS_COMPLETE) { } elseif ($track->status === Track::STATUS_COMPLETE) {
return Response::json(['message' => 'Processing complete!'], 201); return response()->json(['message' => 'Processing complete!'], 201);
} else { } else {
// something went wrong // something went wrong
return Response::json(['error' => 'Processing failed!'], 500); return response()->json(['error' => 'Processing failed!'], 500);
} }
} }
@ -68,9 +68,9 @@ class TracksController extends ApiControllerBase
return $this->execute(new DeleteTrackCommand($id)); return $this->execute(new DeleteTrackCommand($id));
} }
public function postEdit($id) public function postEdit(Request $request, $id)
{ {
return $this->execute(new EditTrackCommand($id, Request::all())); return $this->execute(new EditTrackCommand($id, $request->all()));
} }
public function postUploadNewVersion($trackId) public function postUploadNewVersion($trackId)
@ -95,12 +95,12 @@ class TracksController extends ApiControllerBase
$this->authorize('edit', $track); $this->authorize('edit', $track);
if ($track->version_upload_status === Track::STATUS_PROCESSING) { if ($track->version_upload_status === Track::STATUS_PROCESSING) {
return Response::json(['message' => 'Processing...'], 202); return response()->json(['message' => 'Processing...'], 202);
} elseif ($track->version_upload_status === Track::STATUS_COMPLETE) { } elseif ($track->version_upload_status === Track::STATUS_COMPLETE) {
return Response::json(['message' => 'Processing complete!'], 201); return response()->json(['message' => 'Processing complete!'], 201);
} else { } else {
// something went wrong // something went wrong
return Response::json(['error' => 'Processing failed!'], 500); return response()->json(['error' => 'Processing failed!'], 500);
} }
} }
@ -119,7 +119,7 @@ class TracksController extends ApiControllerBase
]; ];
} }
return Response::json(['current_version' => $track->current_version, 'versions' => $versions], 200); return response()->json(['current_version' => $track->current_version, 'versions' => $versions], 200);
} }
public function getChangeVersion($trackId, $newVersion) public function getChangeVersion($trackId, $newVersion)
@ -142,14 +142,14 @@ class TracksController extends ApiControllerBase
return $this->execute(new GenerateTrackFilesCommand($track, $sourceFile, false, false, true, $newVersion)); return $this->execute(new GenerateTrackFilesCommand($track, $sourceFile, false, false, true, $newVersion));
} }
public function getShow($id) public function getShow(Request $request, $id)
{ {
$track = Track::userDetails()->withComments()->find($id); $track = Track::userDetails()->withComments()->find($id);
if (! $track || ! $track->canView(Auth::user())) { if (! $track || ! $track->canView($request->user())) {
return $this->notFound('Track not found!'); return $this->notFound('Track not found!');
} }
if (Request::get('log')) { if ($request->get('log')) {
ResourceLogItem::logItem('track', $id, ResourceLogItem::VIEW); ResourceLogItem::logItem('track', $id, ResourceLogItem::VIEW);
$track->view_count++; $track->view_count++;
} }
@ -159,10 +159,10 @@ class TracksController extends ApiControllerBase
unset($returned_track['formats']); unset($returned_track['formats']);
} }
return Response::json(['track' => $returned_track], 200); return response()->json(['track' => $returned_track], 200);
} }
public function getCachedTrack($id, $format) public function getCachedTrack(Request $request, $id, $format)
{ {
// Validation // Validation
try { try {
@ -171,7 +171,7 @@ class TracksController extends ApiControllerBase
return $this->notFound('Track not found!'); return $this->notFound('Track not found!');
} }
if (! $track->canView(Auth::user())) { if (! $track->canView($request->user())) {
return $this->notFound('Track not found!'); return $this->notFound('Track not found!');
} }
@ -199,16 +199,16 @@ class TracksController extends ApiControllerBase
$url = null; $url = null;
} }
return Response::json(['url' => $url], 200); return response()->json(['url' => $url], 200);
} }
public function getIndex($all = false, $unknown = false) public function getIndex(Request $request, $all = false, $unknown = false)
{ {
$page = 1; $page = 1;
$perPage = 45; $perPage = 45;
if (Request::has('page')) { if ($request->has('page')) {
$page = Request::get('page'); $page = $request->get('page');
} }
if ($all) { if ($all) {
@ -240,7 +240,7 @@ class TracksController extends ApiControllerBase
$ids[] = $track->id; $ids[] = $track->id;
} }
return Response::json([ return response()->json([
'tracks' => $tracks, 'tracks' => $tracks,
'current_page' => $page, 'current_page' => $page,
'total_pages' => ceil($totalCount / $perPage), 'total_pages' => ceil($totalCount / $perPage),
@ -263,14 +263,14 @@ class TracksController extends ApiControllerBase
public function getOwned(User $user) public function getOwned(User $user)
{ {
$query = Track::summary()->where('user_id', $user->id)->orderBy('created_at', 'desc'); $query = Track::summary()->where('user_id', $user->id)->orderByDesc('created_at');
$tracks = []; $tracks = [];
foreach ($query->get() as $track) { foreach ($query->get() as $track) {
$tracks[] = Track::mapPrivateTrackSummary($track); $tracks[] = Track::mapPrivateTrackSummary($track);
} }
return Response::json($tracks, 200); return response()->json($tracks, 200);
} }
public function getEdit($id) public function getEdit($id)
@ -282,7 +282,7 @@ class TracksController extends ApiControllerBase
$this->authorize('edit', $track); $this->authorize('edit', $track);
return Response::json(Track::mapPrivateTrackShow($track), 200); return response()->json(Track::mapPrivateTrackShow($track), 200);
} }
/** /**

View file

@ -21,7 +21,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Commands\CommandBase; use App\Commands\CommandBase;
use Response; use Illuminate\Support\Facades\Response;
abstract class ApiControllerBase extends Controller abstract class ApiControllerBase extends Controller
{ {
@ -40,22 +40,22 @@ abstract class ApiControllerBase extends Controller
$result = $command->execute(); $result = $command->execute();
if ($result->didFail()) { if ($result->didFail()) {
return Response::json([ return response()->json([
'message' => 'Validation failed', 'message' => 'Validation failed',
'errors' => $result->getMessages(), 'errors' => $result->getMessages(),
], $result->getStatusCode()); ], $result->getStatusCode());
} }
return Response::json($result->getResponse(), $result->getStatusCode()); return response()->json($result->getResponse(), $result->getStatusCode());
} }
public function notAuthorized() public function notAuthorized()
{ {
return Response::json(['message' => 'You may not do this!'], 403); return response()->json(['message' => 'You may not do this!'], 403);
} }
public function notFound($message) public function notFound($message)
{ {
return Response::json(['message' => $message], 403); return response()->json(['message' => $message], 403);
} }
} }

View file

@ -20,10 +20,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App;
use App\Models\User; use App\Models\User;
use Redirect; use Illuminate\Support\Facades\App;
use View; use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
class ArtistsController extends Controller class ArtistsController extends Controller
{ {

View file

@ -22,15 +22,15 @@ namespace App\Http\Controllers;
use App\Models\Activity; use App\Models\Activity;
use App\Models\User; use App\Models\User;
use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use DB; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException; use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken; use League\OAuth2\Client\Token\AccessToken;
use Log;
use Poniverse\Lib\Client; use Poniverse\Lib\Client;
use Redirect;
use Request;
class AuthController extends Controller class AuthController extends Controller
{ {
@ -50,23 +50,23 @@ class AuthController extends Controller
->getAuthorizationUrl()); ->getAuthorizationUrl());
} }
return redirect('/'); return redirect()->to('/');
} }
public function postLogout() public function postLogout()
{ {
Auth::logout(); Auth::logout();
return redirect('/'); return redirect()->to('/');
} }
public function getOAuth() public function getOAuth(Request $request)
{ {
$oauthProvider = $this->poniverse->getOAuthProvider(); $oauthProvider = $this->poniverse->getOAuthProvider();
try { try {
$accessToken = $oauthProvider->getAccessToken('authorization_code', [ $accessToken = $oauthProvider->getAccessToken('authorization_code', [
'code' => Request::query('code'), 'code' => $request->query('code'),
'redirect_uri' => action('AuthController@getOAuth'), 'redirect_uri' => action('AuthController@getOAuth'),
]); ]);
$this->poniverse->setAccessToken($accessToken); $this->poniverse->setAccessToken($accessToken);
@ -74,7 +74,7 @@ class AuthController extends Controller
} catch (IdentityProviderException $e) { } catch (IdentityProviderException $e) {
Log::error($e); Log::error($e);
return redirect('/')->with( return redirect()->to('/')->with(
'message', 'message',
'Unfortunately we are having problems attempting to log you in at the moment. Please try again at a later time.' 'Unfortunately we are having problems attempting to log you in at the moment. Please try again at a later time.'
); );
@ -129,14 +129,14 @@ class AuthController extends Controller
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function postPoniverseAccountSync() public function postPoniverseAccountSync(Request $request)
{ {
$poniverseId = Request::get('id'); $poniverseId = $request->get('id');
$updatedAttribute = Request::get('attribute'); $updatedAttribute = $request->get('attribute');
// Only email address updates are supported at this time. // Only email address updates are supported at this time.
if ('email' !== $updatedAttribute) { if ('email' !== $updatedAttribute) {
return \Response::json(['message' => 'Unsupported Poniverse account attribute.'], 400); return response()->json(['message' => 'Unsupported Poniverse account attribute.'], 400);
} }
$user = User::wherePoniverseId($poniverseId)->first(); $user = User::wherePoniverseId($poniverseId)->first();
@ -154,13 +154,13 @@ class AuthController extends Controller
$user->{$updatedAttribute} = $newUserData->{$updatedAttribute}; $user->{$updatedAttribute} = $newUserData->{$updatedAttribute};
$user->save(); $user->save();
return \Response::json(['message' => 'Successfully updated this user!'], 200); return response()->json(['message' => 'Successfully updated this user!'], 200);
} }
protected function loginRedirect($user, $rememberMe = true) protected function loginRedirect($user, $rememberMe = true)
{ {
Auth::login($user, $rememberMe); Auth::login($user, $rememberMe);
return redirect('/'); return redirect()->to('/');
} }
} }

View file

@ -20,7 +20,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use View; use Illuminate\Support\Facades\View;
class ContentController extends Controller class ContentController extends Controller
{ {

View file

@ -20,7 +20,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use View; use Illuminate\Support\Facades\View;
class HomeController extends Controller class HomeController extends Controller
{ {

View file

@ -20,11 +20,11 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App;
use App\Models\Image; use App\Models\Image;
use Config; use Illuminate\Support\Facades\App;
use Redirect; use Illuminate\Support\Facades\Config;
use Response; use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Response;
class ImagesController extends Controller class ImagesController extends Controller
{ {
@ -41,13 +41,13 @@ class ImagesController extends Controller
abort(404); abort(404);
} }
$response = response('', 200); $response = response()->noContent(200);
$filename = $image->getFile($coverType['id']); $filename = $image->getFile($coverType['id']);
if (! is_file($filename)) { if (! is_file($filename)) {
$redirect = url('/images/icons/profile_'.Image::$ImageTypes[$coverType['id']]['name'].'.png'); $redirect = url('/images/icons/profile_'.Image::$ImageTypes[$coverType['id']]['name'].'.png');
return redirect($redirect); return redirect()->to($redirect);
} }
if (config('app.sendfile')) { if (config('app.sendfile')) {

View file

@ -20,12 +20,13 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App;
use App\Models\Email; use App\Models\Email;
use App\Models\EmailSubscription; use App\Models\EmailSubscription;
use Auth; use Illuminate\Http\Request;
use DB; use Illuminate\Support\Facades\App;
use View; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\View;
class NotificationsController extends Controller class NotificationsController extends Controller
{ {
@ -33,36 +34,36 @@ class NotificationsController extends Controller
* @param $emailKey * @param $emailKey
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/ */
public function getEmailClick($emailKey) public function getEmailClick(Request $request, $emailKey)
{ {
/** @var Email $email */ /** @var Email $email */
$email = Email::findOrFail($emailKey); $email = Email::findOrFail($emailKey);
DB::transaction(function () use ($email) { DB::transaction(function () use ($email) {
$email->emailClicks()->create(['ip_address' => \Request::ip()]); $email->emailClicks()->create(['ip_address' => $request->ip()]);
$email->notification->is_read = true; $email->notification->is_read = true;
$email->notification->save(); $email->notification->save();
}); });
return redirect($email->getActivity()->url); return redirect()->to($email->getActivity()->url);
} }
public function getEmailUnsubscribe($subscriptionKey) public function getEmailUnsubscribe(Request $request, $subscriptionKey)
{ {
/** @var EmailSubscription $subscription */ /** @var EmailSubscription $subscription */
$subscription = EmailSubscription::findOrFail($subscriptionKey); $subscription = EmailSubscription::findOrFail($subscriptionKey);
$subscription->delete(); $subscription->delete();
if (Auth::check() && $subscription->user->id === Auth::user()->id) { if ($request->user() && $subscription->user->id === $request->user()->id) {
return redirect(route('account:settings', [ return redirect(route('account:settings', [
'slug' => $subscription->user->slug, 'slug' => $subscription->user->slug,
'unsubscribedMessageKey' => $subscription->activity_type, 'unsubscribedMessageKey' => $subscription->activity_type,
]), 303); ]), );
} else { } else {
return redirect(route('email:confirm-unsubscribed', [ return redirect(route('email:confirm-unsubscribed', [
'unsubscribedUser' => $subscription->user->display_name, 'unsubscribedUser' => $subscription->user->display_name,
'unsubscribedMessageKey' => $subscription->activity_type, 'unsubscribedMessageKey' => $subscription->activity_type,
]), 303); ]), );
} }
} }

View file

@ -20,14 +20,15 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\ResourceLogItem; use App\Models\ResourceLogItem;
use App\Models\Track; use App\Models\Track;
use App\PlaylistDownloader; use App\PlaylistDownloader;
use Auth; use Illuminate\Http\Request;
use Redirect; use Illuminate\Support\Facades\App;
use View; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
class PlaylistsController extends Controller class PlaylistsController extends Controller
{ {
@ -36,10 +37,10 @@ class PlaylistsController extends Controller
return view('playlists.index'); return view('playlists.index');
} }
public function getPlaylist($id, $slug) public function getPlaylist(Request $request, $id, $slug)
{ {
$playlist = Playlist::find($id); $playlist = Playlist::find($id);
if (! $playlist || ! $playlist->canView(Auth::user())) { if (! $playlist || ! $playlist->canView($request->user())) {
abort(404); abort(404);
} }
@ -50,20 +51,20 @@ class PlaylistsController extends Controller
return view('playlists.show'); return view('playlists.show');
} }
public function getShortlink($id) public function getShortlink(Request $request, $id)
{ {
$playlist = Playlist::find($id); $playlist = Playlist::find($id);
if (! $playlist || ! $playlist->canView(Auth::user())) { if (! $playlist || ! $playlist->canView($request->user())) {
abort(404); abort(404);
} }
return Redirect::action('PlaylistsController@getPlaylist', [$id, $playlist->slug]); return Redirect::action('PlaylistsController@getPlaylist', [$id, $playlist->slug]);
} }
public function getDownload($id, $extension) public function getDownload(Request $request, $id, $extension)
{ {
$playlist = Playlist::with('tracks', 'tracks.trackFiles', 'user', 'tracks.album')->find($id); $playlist = Playlist::with('tracks', 'tracks.trackFiles', 'user', 'tracks.album')->find($id);
if (! $playlist || ! $playlist->canView(Auth::user())) { if (! $playlist || ! $playlist->canView($request->user())) {
abort(404); abort(404);
} }
@ -88,6 +89,6 @@ class PlaylistsController extends Controller
ResourceLogItem::logItem('playlist', $id, ResourceLogItem::DOWNLOAD, $format['index']); ResourceLogItem::logItem('playlist', $id, ResourceLogItem::DOWNLOAD, $format['index']);
$downloader = new PlaylistDownloader($playlist, $formatName); $downloader = new PlaylistDownloader($playlist, $formatName);
$downloader->download(Auth::user()); $downloader->download($request->user());
} }
} }

View file

@ -20,7 +20,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use View; use Illuminate\Support\Facades\View;
class StatsController extends Controller class StatsController extends Controller
{ {

View file

@ -20,16 +20,16 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App;
use App\Models\ResourceLogItem; use App\Models\ResourceLogItem;
use App\Models\Track; use App\Models\Track;
use App\Models\TrackFile; use App\Models\TrackFile;
use Auth;
use Config;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Redirect; use Illuminate\Support\Facades\App;
use Response; use Illuminate\Support\Facades\Auth;
use View; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\View;
class TracksController extends Controller class TracksController extends Controller
{ {
@ -38,7 +38,7 @@ class TracksController extends Controller
return view('tracks.index'); return view('tracks.index');
} }
public function getEmbed($id) public function getEmbed(Request $request, $id)
{ {
$track = Track $track = Track
::whereId($id) ::whereId($id)
@ -50,7 +50,7 @@ class TracksController extends Controller
'genre' 'genre'
)->first(); )->first();
if (! $track || ! $track->canView(Auth::user())) { if (! $track || ! $track->canView($request->user())) {
abort(404); abort(404);
} }
@ -93,7 +93,7 @@ class TracksController extends Controller
->userDetails() ->userDetails()
->first(); ->first();
if (! $track || ! $track->canView(Auth::user())) { if (! $track || ! $track->canView($request->user())) {
abort(404); abort(404);
} }
@ -110,13 +110,13 @@ class TracksController extends Controller
'html' => '<iframe src="'.action('TracksController@getEmbed', ['id' => $track->id]).'" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>', 'html' => '<iframe src="'.action('TracksController@getEmbed', ['id' => $track->id]).'" width="100%" height="150" allowTransparency="true" frameborder="0" seamless allowfullscreen></iframe>',
]; ];
return Response::json($output); return response()->json($output);
} }
public function getTrack($id, $slug) public function getTrack(Request $request, $id, $slug)
{ {
$track = Track::find($id); $track = Track::find($id);
if (! $track || ! $track->canView(Auth::user())) { if (! $track || ! $track->canView($request->user())) {
abort(404); abort(404);
} }
@ -132,26 +132,26 @@ class TracksController extends Controller
return $this->getTrack($id, $slug); return $this->getTrack($id, $slug);
} }
public function getShortlink($id) public function getShortlink(Request $request, $id)
{ {
$track = Track::find($id); $track = Track::find($id);
if (! $track || ! $track->canView(Auth::user())) { if (! $track || ! $track->canView($request->user())) {
abort(404); abort(404);
} }
return Redirect::action('TracksController@getTrack', [$id, $track->slug]); return Redirect::action('TracksController@getTrack', [$id, $track->slug]);
} }
public function getStream($id, $extension) public function getStream(Request $request, $id, $extension)
{ {
$track = Track::find($id); $track = Track::find($id);
if (! $track || ! $track->canView(Auth::user())) { if (! $track || ! $track->canView($request->user())) {
abort(404); abort(404);
} }
$trackFile = TrackFile::findOrFailByExtension($track->id, $extension); $trackFile = TrackFile::findOrFailByExtension($track->id, $extension);
$response = response('', 200); $response = response()->noContent(200);
$filename = $trackFile->getFile(); $filename = $trackFile->getFile();
if (! file_exists($filename)) { if (! file_exists($filename)) {
@ -179,17 +179,17 @@ class TracksController extends Controller
return $response; return $response;
} }
public function getDownload($id, $extension) public function getDownload(Request $request, $id, $extension)
{ {
$track = Track::find($id); $track = Track::find($id);
if (! $track || ! $track->canView(Auth::user())) { if (! $track || ! $track->canView($request->user())) {
abort(404); abort(404);
} }
$trackFile = TrackFile::findOrFailByExtension($track->id, $extension); $trackFile = TrackFile::findOrFailByExtension($track->id, $extension);
ResourceLogItem::logItem('track', $id, ResourceLogItem::DOWNLOAD, $trackFile->getFormat()['index']); ResourceLogItem::logItem('track', $id, ResourceLogItem::DOWNLOAD, $trackFile->getFormat()['index']);
$response = response('', 200); $response = response()->noContent(200);
$filename = $trackFile->getFile(); $filename = $trackFile->getFile();
if (config('app.sendfile')) { if (config('app.sendfile')) {

View file

@ -20,7 +20,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use View; use Illuminate\Support\Facades\View;
class UploaderController extends Controller class UploaderController extends Controller
{ {

View file

@ -21,8 +21,8 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Closure; use Closure;
use Gate;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Illuminate\Support\Facades\Gate;
class Authorize class Authorize
{ {

View file

@ -22,7 +22,7 @@ namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Auth\Guard;
use Log; use Illuminate\Support\Facades\Log;
class DisabledAccountCheck class DisabledAccountCheck
{ {

View file

@ -40,7 +40,7 @@ class JsonExceptions
try { try {
$response = $next($request); $response = $next($request);
} catch (HttpException $e) { } catch (HttpException $e) {
return \Response::json([ return response()->json([
'message' => $e->getMessage(), 'message' => $e->getMessage(),
], $e->getStatusCode()); ], $e->getStatusCode());
} }

View file

@ -41,7 +41,7 @@ class RedirectIfAuthenticated
foreach ($guards as $guard) { foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) { if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME); return redirect()->to(RouteServiceProvider::HOME);
} }
} }

View file

@ -22,10 +22,10 @@ namespace App\Jobs;
use App\Models\Genre; use App\Models\Genre;
use App\Models\Track; use App\Models\Track;
use Auth;
use DB;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use SerializesModels; use SerializesModels;
class DeleteGenre extends Job implements ShouldQueue class DeleteGenre extends Job implements ShouldQueue

View file

@ -22,10 +22,10 @@ namespace App\Jobs;
use App\Models\ShowSong; use App\Models\ShowSong;
use App\Models\Track; use App\Models\Track;
use Auth;
use DB;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use SerializesModels; use SerializesModels;
class DeleteShowSong extends Job implements ShouldQueue class DeleteShowSong extends Job implements ShouldQueue

View file

@ -25,13 +25,13 @@ use App\Exceptions\InvalidEncodeOptionsException;
use App\Models\Track; use App\Models\Track;
use App\Models\TrackFile; use App\Models\TrackFile;
use Carbon\Carbon; use Carbon\Carbon;
use Config;
use DB;
use File;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Log; use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;

View file

@ -20,9 +20,9 @@
namespace App\Jobs; namespace App\Jobs;
use App;
use DB;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\DB;
abstract class Job abstract class Job
{ {

View file

@ -22,10 +22,10 @@ namespace App\Jobs;
use App\Contracts\Searchable; use App\Contracts\Searchable;
use App\Jobs\Job; use App\Jobs\Job;
use DB;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\DB;
use SerializesModels; use SerializesModels;
class UpdateSearchIndexForEntity extends Job implements ShouldQueue class UpdateSearchIndexForEntity extends Job implements ShouldQueue

View file

@ -22,12 +22,12 @@ namespace App\Jobs;
use App\Models\Genre; use App\Models\Genre;
use App\Models\Track; use App\Models\Track;
use Auth;
use Cache;
use DB;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Log; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use SerializesModels; use SerializesModels;
/** /**

View file

@ -22,11 +22,11 @@ namespace App\Jobs;
use App\Models\ShowSong; use App\Models\ShowSong;
use App\Models\Track; use App\Models\Track;
use Auth;
use Cache;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Log; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use SerializesModels; use SerializesModels;
/** /**

View file

@ -26,7 +26,7 @@ use App\Models\Comment;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Config; use Illuminate\Support\Facades\Config;
use Minishlink\WebPush\WebPush; use Minishlink\WebPush\WebPush;
class NativeDriver extends AbstractDriver class NativeDriver extends AbstractDriver

View file

@ -30,8 +30,8 @@ use App\Models\Playlist;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use Carbon\Carbon; use Carbon\Carbon;
use Log; use Illuminate\Support\Facades\Log;
use Mail; use Illuminate\Support\Facades\Mail;
class PonyfmDriver extends AbstractDriver class PonyfmDriver extends AbstractDriver
{ {

View file

@ -24,10 +24,10 @@ use App\Models\Album;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\Track; use App\Models\Track;
use App\Models\User; use App\Models\User;
use DB;
use Elasticsearch\Client; use Elasticsearch\Client;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\DB;
class Search class Search
{ {

View file

@ -557,7 +557,7 @@ class ZipStream
*/ */
public static function getRelativePath($path) public static function getRelativePath($path)
{ {
$path = preg_replace("#/+\.?/+#", '/', str_replace('\\', '/', $path)); $path = preg_replace('#/+\\.?/+#', '/', str_replace('\\', '/', $path));
$dirs = explode('/', rtrim(preg_replace('#^(?:\./)+#', '', $path), '/')); $dirs = explode('/', rtrim(preg_replace('#^(?:\./)+#', '', $path), '/'));
$offset = 0; $offset = 0;

View file

@ -1427,15 +1427,15 @@ if (! function_exists('IsValidURL')) {
if ($parts = safe_parse_url($url)) { if ($parts = safe_parse_url($url)) {
if (($parts['scheme'] != 'http') && ($parts['scheme'] != 'https') && ($parts['scheme'] != 'ftp') && ($parts['scheme'] != 'gopher')) { if (($parts['scheme'] != 'http') && ($parts['scheme'] != 'https') && ($parts['scheme'] != 'ftp') && ($parts['scheme'] != 'gopher')) {
return false; return false;
} elseif (! preg_match("#^[[:alnum:]]([-.]?[0-9a-z])*\.[a-z]{2,3}#i$", $parts['host'], $regs) && ! preg_match('#^[0-9]{1,3}(\.[0-9]{1,3}){3}$#', $parts['host'])) { } elseif (! preg_match('#^[[:alnum:]]([-.]?[0-9a-z])*\\.[a-z]{2,3}#i$', $parts['host'], $regs) && ! preg_match('#^[0-9]{1,3}(\.[0-9]{1,3}){3}$#', $parts['host'])) {
return false; return false;
} elseif (! preg_match("#^([[:alnum:]-]|[\_])*$#i", $parts['user'], $regs)) { } elseif (! preg_match('#^([[:alnum:]-]|[\\_])*$#i', $parts['user'], $regs)) {
return false; return false;
} elseif (! preg_match("#^([[:alnum:]-]|[\_])*$#i", $parts['pass'], $regs)) { } elseif (! preg_match('#^([[:alnum:]-]|[\\_])*$#i', $parts['pass'], $regs)) {
return false; return false;
} elseif (! preg_match("#^[[:alnum:]/_\.@~-]*$#i", $parts['path'], $regs)) { } elseif (! preg_match('#^[[:alnum:]/_\\.@~-]*$#i', $parts['path'], $regs)) {
return false; return false;
} elseif (! preg_match("#^[[:alnum:]?&=+:;_()%#/,\.-]*$#i", $parts['query'], $regs)) { } elseif (! preg_match('#^[[:alnum:]?&=+:;_()%#/,\\.-]*$#i', $parts['query'], $regs)) {
return false; return false;
} else { } else {
return true; return true;

View file

@ -59,7 +59,7 @@ class Activity extends Model
use SoftDeletes; use SoftDeletes;
public $timestamps = false; public $timestamps = false;
protected $dates = ['created_at'];
protected $fillable = ['created_at', 'user_id', 'activity_type', 'resource_type', 'resource_id']; protected $fillable = ['created_at', 'user_id', 'activity_type', 'resource_type', 'resource_id'];
protected $appends = ['url', 'thumbnail_url', 'human_friendly_resource_type']; protected $appends = ['url', 'thumbnail_url', 'human_friendly_resource_type'];
protected $casts = [ protected $casts = [

View file

@ -27,17 +27,17 @@ use App\Exceptions\TrackFileNotFoundException;
use App\Traits\IndexedInElasticsearchTrait; use App\Traits\IndexedInElasticsearchTrait;
use App\Traits\SlugTrait; use App\Traits\SlugTrait;
use App\Traits\TrackCollection; use App\Traits\TrackCollection;
use Auth;
use Cache;
use DB;
use Exception; use Exception;
use Gate;
use Helpers; use Helpers;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Gate;
use Venturecraft\Revisionable\RevisionableTrait; use Venturecraft\Revisionable\RevisionableTrait;
/** /**
@ -126,8 +126,6 @@ class Album extends Model implements Searchable, Commentable, Favouritable
return $query; return $query;
} }
protected $table = 'albums';
public function user() public function user()
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);
@ -150,7 +148,7 @@ class Album extends Model implements Searchable, Commentable, Favouritable
public function tracks() public function tracks()
{ {
return $this->hasMany(Track::class)->orderBy('track_number', 'asc'); return $this->hasMany(Track::class)->orderBy('track_number');
} }
public function trackFiles() public function trackFiles()
@ -162,7 +160,7 @@ class Album extends Model implements Searchable, Commentable, Favouritable
public function comments():HasMany public function comments():HasMany
{ {
return $this->hasMany(Comment::class)->orderBy('created_at', 'desc'); return $this->hasMany(Comment::class)->orderByDesc('created_at');
} }
public function activities():MorphMany public function activities():MorphMany

View file

@ -49,8 +49,6 @@ use Illuminate\Database\Eloquent\Model;
*/ */
class Announcement extends Model class Announcement extends Model
{ {
protected $table = 'announcements';
protected $casts = [ protected $casts = [
'links' => 'array', 'links' => 'array',
'tracks' => 'array', 'tracks' => 'array',

View file

@ -21,10 +21,10 @@
namespace App\Models; namespace App\Models;
use App\Contracts\Commentable; use App\Contracts\Commentable;
use DB;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
/** /**
* App\Models\Comment. * App\Models\Comment.
@ -70,8 +70,6 @@ class Comment extends Model
{ {
use SoftDeletes; use SoftDeletes;
protected $table = 'comments';
public function user() public function user()
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);

View file

@ -47,7 +47,6 @@ use Illuminate\Database\Eloquent\Model;
*/ */
class Favourite extends Model class Favourite extends Model
{ {
protected $table = 'favourites';
public $timestamps = false; public $timestamps = false;
/* /*

View file

@ -42,8 +42,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
*/ */
class Follower extends Model class Follower extends Model
{ {
protected $table = 'followers';
public $timestamps = false; public $timestamps = false;
public function follower():BelongsTo public function follower():BelongsTo

View file

@ -21,11 +21,11 @@
namespace App\Models; namespace App\Models;
use App\Traits\SlugTrait; use App\Traits\SlugTrait;
use DB;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use Venturecraft\Revisionable\RevisionableTrait; use Venturecraft\Revisionable\RevisionableTrait;
/** /**
@ -60,8 +60,6 @@ class Genre extends Model
{ {
use HasFactory; use HasFactory;
protected $table = 'genres';
protected $fillable = ['name', 'slug']; protected $fillable = ['name', 'slug'];
protected $appends = ['track_count', 'url']; protected $appends = ['track_count', 'url'];
protected $hidden = ['trackCountRelation']; protected $hidden = ['trackCountRelation'];

View file

@ -20,9 +20,9 @@
namespace App\Models; namespace App\Models;
use Config;
use External; use External;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
@ -165,8 +165,6 @@ class Image extends Model
chmod($path, 0644); chmod($path, 0644);
} }
protected $table = 'images';
public function getUrl($type = self::NORMAL) public function getUrl($type = self::NORMAL)
{ {
$type = self::$ImageTypes[$type]; $type = self::$ImageTypes[$type];

View file

@ -41,5 +41,4 @@ use Illuminate\Database\Eloquent\Model;
*/ */
class License extends Model class License extends Model
{ {
protected $table = 'licenses';
} }

View file

@ -84,7 +84,7 @@ class Notification extends Model
->where('notifications.user_id', $user->id) ->where('notifications.user_id', $user->id)
->whereNull('activities.deleted_at') ->whereNull('activities.deleted_at')
->select('*', 'notifications.id as id') ->select('*', 'notifications.id as id')
->orderBy('activities.created_at', 'DESC'); ->orderByDesc('activities.created_at');
return $result; return $result;
} }

View file

@ -41,8 +41,6 @@ use Illuminate\Database\Eloquent\Model;
*/ */
class PinnedPlaylist extends Model class PinnedPlaylist extends Model
{ {
protected $table = 'pinned_playlists';
public function user() public function user()
{ {
return $this->belongsTo(User::class); return $this->belongsTo(User::class);

View file

@ -27,15 +27,15 @@ use App\Exceptions\TrackFileNotFoundException;
use App\Traits\IndexedInElasticsearchTrait; use App\Traits\IndexedInElasticsearchTrait;
use App\Traits\SlugTrait; use App\Traits\SlugTrait;
use App\Traits\TrackCollection; use App\Traits\TrackCollection;
use Auth;
use Cache;
use DB;
use Helpers; use Helpers;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Venturecraft\Revisionable\RevisionableTrait; use Venturecraft\Revisionable\RevisionableTrait;
/** /**
@ -94,8 +94,6 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
protected $elasticsearchType = 'playlist'; protected $elasticsearchType = 'playlist';
protected $table = 'playlists';
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'user_id' => 'integer', 'user_id' => 'integer',
@ -244,7 +242,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
->withTimestamps(); ->withTimestamps();
if ($ordered) { if ($ordered) {
$query = $query->orderBy('position', 'asc'); $query = $query->orderBy('position');
} }
return $query; return $query;
@ -269,7 +267,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
public function comments():HasMany public function comments():HasMany
{ {
return $this->hasMany(Comment::class)->orderBy('created_at', 'desc'); return $this->hasMany(Comment::class)->orderByDesc('created_at');
} }
public function pins() public function pins()

View file

@ -20,11 +20,11 @@
namespace App\Models; namespace App\Models;
use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use DB;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Request; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
/** /**
* App\Models\ResourceLogItem. * App\Models\ResourceLogItem.
@ -51,9 +51,7 @@ use Request;
*/ */
class ResourceLogItem extends Model class ResourceLogItem extends Model
{ {
protected $table = 'resource_log_items';
public $timestamps = false; public $timestamps = false;
protected $dates = ['created_at'];
const VIEW = 1; const VIEW = 1;
const DOWNLOAD = 2; const DOWNLOAD = 2;

Some files were not shown because too many files have changed in this diff Show more