From f87b29d064b602e1cc8c89436f6c05ee680f66db Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Sun, 14 Feb 2021 19:38:28 +0000 Subject: [PATCH] Shift to new helper methods Laravel 5 added several new helper functions, including: - `view()` - `response()` - `redirect()` - `config()` - `abort()` Review the [helpers][1] documentation for more details. [1]: https://laravel.com/docs/5.0/helpers --- app/Commands/CreateCommentCommand.php | 4 +-- app/Commands/ParseTrackTagsCommand.php | 2 +- app/Commands/UploadTrackCommand.php | 10 +++---- app/Console/Commands/FixMLPMAImages.php | 4 +-- app/Console/Commands/ImportEQBeats.php | 2 +- app/Console/Commands/MigrateOldData.php | 2 +- app/Http/Controllers/AccountController.php | 6 ++-- app/Http/Controllers/AdminController.php | 14 ++++----- app/Http/Controllers/AlbumsController.php | 14 ++++----- .../Controllers/Api/Web/AlbumsController.php | 2 +- .../Controllers/Api/Web/ArtistsController.php | 6 ++-- .../Api/Web/CommentsController.php | 2 +- .../Api/Web/PlaylistsController.php | 2 +- app/Http/Controllers/ArtistsController.php | 10 +++---- app/Http/Controllers/AuthController.php | 10 +++---- app/Http/Controllers/ContentController.php | 6 ++-- app/Http/Controllers/HomeController.php | 2 +- app/Http/Controllers/ImagesController.php | 10 +++---- .../Controllers/NotificationsController.php | 2 +- app/Http/Controllers/PlaylistsController.php | 14 ++++----- app/Http/Controllers/StatsController.php | 2 +- app/Http/Controllers/TracksController.php | 30 +++++++++---------- app/Http/Controllers/UploaderController.php | 2 +- app/Jobs/EncodeTrackFile.php | 2 +- app/Library/Assets.php | 6 ++-- app/Library/File.php | 2 +- .../Notifications/Drivers/NativeDriver.php | 4 +-- app/Models/Album.php | 2 +- app/Models/Image.php | 2 +- app/Models/Track.php | 8 ++--- app/Models/TrackFile.php | 8 ++--- app/Traits/IndexedInElasticsearchTrait.php | 4 +-- 32 files changed, 98 insertions(+), 98 deletions(-) diff --git a/app/Commands/CreateCommentCommand.php b/app/Commands/CreateCommentCommand.php index 718944a6..6971f9e0 100644 --- a/app/Commands/CreateCommentCommand.php +++ b/app/Commands/CreateCommentCommand.php @@ -88,7 +88,7 @@ class CreateCommentCommand extends CommandBase if ($this->_type == 'playlist') { $column = 'playlist_id'; } else { - App::abort(500); + abort(500); } } } @@ -107,7 +107,7 @@ class CreateCommentCommand extends CommandBase } elseif ($this->_type === 'user') { $entity = User::find($this->_id); } else { - App::abort(400, 'This comment is being added to an invalid entity!'); + abort(400, 'This comment is being added to an invalid entity!'); } $entity->comment_count = Comment::where($column, $this->_id)->count(); diff --git a/app/Commands/ParseTrackTagsCommand.php b/app/Commands/ParseTrackTagsCommand.php index b1486c56..e65e6c21 100755 --- a/app/Commands/ParseTrackTagsCommand.php +++ b/app/Commands/ParseTrackTagsCommand.php @@ -278,7 +278,7 @@ class ParseTrackTagsCommand extends CommandBase } // write temporary image file - $tmpPath = Config::get('ponyfm.files_directory').'/tmp'; + $tmpPath = config('ponyfm.files_directory').'/tmp'; $filename = $file->getFilename().".cover.${extension}"; $imageFilePath = "${tmpPath}/${filename}"; diff --git a/app/Commands/UploadTrackCommand.php b/app/Commands/UploadTrackCommand.php index b1de3c63..e11fef7f 100644 --- a/app/Commands/UploadTrackCommand.php +++ b/app/Commands/UploadTrackCommand.php @@ -134,15 +134,15 @@ class UploadTrackCommand extends CommandBase } $this->_track->ensureDirectoryExists(); - if (! is_dir(Config::get('ponyfm.files_directory').'/tmp')) { - mkdir(Config::get('ponyfm.files_directory').'/tmp', 0755, true); + if (! is_dir(config('ponyfm.files_directory').'/tmp')) { + mkdir(config('ponyfm.files_directory').'/tmp', 0755, true); } - if (! is_dir(Config::get('ponyfm.files_directory').'/queued-tracks')) { - mkdir(Config::get('ponyfm.files_directory').'/queued-tracks', 0755, true); + if (! is_dir(config('ponyfm.files_directory').'/queued-tracks')) { + mkdir(config('ponyfm.files_directory').'/queued-tracks', 0755, true); } - $trackFile = $trackFile->move(Config::get('ponyfm.files_directory').'/queued-tracks', $this->_track->id.'v'.$this->_version); + $trackFile = $trackFile->move(config('ponyfm.files_directory').'/queued-tracks', $this->_track->id.'v'.$this->_version); $input = Request::all(); $input['track'] = $trackFile; diff --git a/app/Console/Commands/FixMLPMAImages.php b/app/Console/Commands/FixMLPMAImages.php index 0b795395..4c346fe2 100644 --- a/app/Console/Commands/FixMLPMAImages.php +++ b/app/Console/Commands/FixMLPMAImages.php @@ -77,8 +77,8 @@ class FixMLPMAImages extends Command */ public function handle() { - $mlpmaPath = Config::get('ponyfm.files_directory').'/mlpma'; - $tmpPath = Config::get('ponyfm.files_directory').'/tmp'; + $mlpmaPath = config('ponyfm.files_directory').'/mlpma'; + $tmpPath = config('ponyfm.files_directory').'/tmp'; $this->comment('Enumerating MLP Music Archive source files...'); $files = File::allFiles($mlpmaPath); diff --git a/app/Console/Commands/ImportEQBeats.php b/app/Console/Commands/ImportEQBeats.php index c4c69af6..ddc02a8b 100644 --- a/app/Console/Commands/ImportEQBeats.php +++ b/app/Console/Commands/ImportEQBeats.php @@ -86,7 +86,7 @@ class ImportEQBeats extends Command pcntl_signal(SIGINT, [$this, 'handleInterrupt']); $archivePath = $this->argument('archiveFolder'); - $tmpPath = Config::get('ponyfm.files_directory').'/tmp'; + $tmpPath = config('ponyfm.files_directory').'/tmp'; if (! File::exists($tmpPath)) { File::makeDirectory($tmpPath); diff --git a/app/Console/Commands/MigrateOldData.php b/app/Console/Commands/MigrateOldData.php index 7887d065..6060e241 100644 --- a/app/Console/Commands/MigrateOldData.php +++ b/app/Console/Commands/MigrateOldData.php @@ -399,6 +399,6 @@ class MigrateOldData extends Command { $dir = (string) (floor($id / 100) * 100); - return \Config::get('ponyfm.files_directory').'/'.$type.'/'.$dir; + return config('ponyfm.files_directory').'/'.$type.'/'.$dir; } } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index f2e72556..01b2a13a 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -28,16 +28,16 @@ class AccountController extends Controller { public function getIndex() { - return View::make('shared.null'); + return view('shared.null'); } public function getRegister() { - return Redirect::to(Config::get('poniverse.urls')['register']); + return redirect(config('poniverse.urls')['register']); } public function getNotifications() { - return View::make('shared.null'); + return view('shared.null'); } } diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 63a72656..c1073a8c 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -26,36 +26,36 @@ class AdminController extends Controller { public function getIndex() { - return View::make('shared.null'); + return view('shared.null'); } public function getGenres() { - return View::make('shared.null'); + return view('shared.null'); } public function getTracks() { - return View::make('shared.null'); + return view('shared.null'); } public function getShowSongs() { - return View::make('shared.null'); + return view('shared.null'); } public function getUsers() { - return View::make('shared.null'); + return view('shared.null'); } public function getClassifierQueue() { - return View::make('shared.null'); + return view('shared.null'); } public function getAnnouncements() { - return View::make('shared.null'); + return view('shared.null'); } } diff --git a/app/Http/Controllers/AlbumsController.php b/app/Http/Controllers/AlbumsController.php index 611d8b7b..f70e4fca 100644 --- a/app/Http/Controllers/AlbumsController.php +++ b/app/Http/Controllers/AlbumsController.php @@ -32,28 +32,28 @@ class AlbumsController extends Controller { public function getIndex() { - return View::make('albums.index'); + return view('albums.index'); } public function getShow($id, $slug) { $album = Album::find($id); if (! $album) { - App::abort(404); + abort(404); } if ($album->slug != $slug) { return Redirect::action('AlbumsController@getAlbum', [$id, $album->slug]); } - return View::make('albums.show'); + return view('albums.show'); } public function getShortlink($id) { $album = Album::find($id); if (! $album) { - App::abort(404); + abort(404); } return Redirect::action('AlbumsController@getShow', [$id, $album->slug]); @@ -63,7 +63,7 @@ class AlbumsController extends Controller { $album = Album::with('tracks', 'tracks.trackFiles', 'user')->find($id); if (! $album) { - App::abort(404); + abort(404); } $format = null; @@ -78,11 +78,11 @@ class AlbumsController extends Controller } if ($format == null) { - App::abort(404); + abort(404); } if (! $album->hasLosslessTracks() && in_array($formatName, Track::$LosslessFormats)) { - App::abort(404); + abort(404); } ResourceLogItem::logItem('album', $id, ResourceLogItem::DOWNLOAD, $format['index']); diff --git a/app/Http/Controllers/Api/Web/AlbumsController.php b/app/Http/Controllers/Api/Web/AlbumsController.php index 6be5b060..110237fd 100644 --- a/app/Http/Controllers/Api/Web/AlbumsController.php +++ b/app/Http/Controllers/Api/Web/AlbumsController.php @@ -72,7 +72,7 @@ class AlbumsController extends ApiControllerBase ->find($id); if (! $album) { - App::abort(404); + abort(404); } if (Request::get('log')) { diff --git a/app/Http/Controllers/Api/Web/ArtistsController.php b/app/Http/Controllers/Api/Web/ArtistsController.php index 68ec8ff2..99bc32a7 100644 --- a/app/Http/Controllers/Api/Web/ArtistsController.php +++ b/app/Http/Controllers/Api/Web/ArtistsController.php @@ -42,7 +42,7 @@ class ArtistsController extends ApiControllerBase { $user = User::where('slug', $slug)->whereNull('disabled_at')->first(); if (! $user) { - App::abort(404); + abort(404); } $favs = Favourite::where('user_id', $user->id) @@ -88,7 +88,7 @@ class ArtistsController extends ApiControllerBase { $user = User::where('slug', $slug)->whereNull('disabled_at')->first(); if (! $user) { - App::abort(404); + abort(404); } $query = Track::summary() @@ -137,7 +137,7 @@ class ArtistsController extends ApiControllerBase ]) ->first(); if (! $user) { - App::abort(404); + abort(404); } $trackQuery = Track::summary() diff --git a/app/Http/Controllers/Api/Web/CommentsController.php b/app/Http/Controllers/Api/Web/CommentsController.php index 0a9297d3..5b75fe40 100644 --- a/app/Http/Controllers/Api/Web/CommentsController.php +++ b/app/Http/Controllers/Api/Web/CommentsController.php @@ -50,7 +50,7 @@ class CommentsController extends ApiControllerBase if ($type == 'playlist') { $column = 'playlist_id'; } else { - App::abort(500); + abort(500); } } } diff --git a/app/Http/Controllers/Api/Web/PlaylistsController.php b/app/Http/Controllers/Api/Web/PlaylistsController.php index 01c07ce6..0c1baed5 100644 --- a/app/Http/Controllers/Api/Web/PlaylistsController.php +++ b/app/Http/Controllers/Api/Web/PlaylistsController.php @@ -116,7 +116,7 @@ class PlaylistsController extends ApiControllerBase 'comments.user', ])->userDetails()->find($id); if (! $playlist || ! $playlist->canView(Auth::user())) { - App::abort('404'); + abort('404'); } if (Request::get('log')) { diff --git a/app/Http/Controllers/ArtistsController.php b/app/Http/Controllers/ArtistsController.php index 204e5769..2e6aa64d 100644 --- a/app/Http/Controllers/ArtistsController.php +++ b/app/Http/Controllers/ArtistsController.php @@ -29,7 +29,7 @@ class ArtistsController extends Controller { public function getIndex() { - return View::make('artists.index'); + return view('artists.index'); } public function getFavourites($slug) @@ -56,12 +56,12 @@ class ArtistsController extends Controller } if ($user->disabled_at) { - App::abort('404'); + abort('404'); } - return View::make('artists.profile'); + return view('artists.profile'); } else { - App::abort('404'); + abort('404'); } } @@ -69,7 +69,7 @@ class ArtistsController extends Controller { $user = User::find($id); if (! $user || $user->disabled_at !== null) { - App::abort('404'); + abort('404'); } return Redirect::action('ArtistsController@getProfile', [$user->slug]); diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 7076f09f..310c89e9 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -44,20 +44,20 @@ class AuthController extends Controller public function getLogin() { if (Auth::guest()) { - return Redirect::to( + return redirect( $this->poniverse ->getOAuthProvider(['redirectUri' => action('AuthController@getOAuth')]) ->getAuthorizationUrl()); } - return Redirect::to('/'); + return redirect('/'); } public function postLogout() { Auth::logout(); - return Redirect::to('/'); + return redirect('/'); } public function getOAuth() @@ -74,7 +74,7 @@ class AuthController extends Controller } catch (IdentityProviderException $e) { Log::error($e); - return Redirect::to('/')->with( + return redirect('/')->with( 'message', 'Unfortunately we are having problems attempting to log you in at the moment. Please try again at a later time.' ); @@ -161,6 +161,6 @@ class AuthController extends Controller { Auth::login($user, $rememberMe); - return Redirect::to('/'); + return redirect('/'); } } diff --git a/app/Http/Controllers/ContentController.php b/app/Http/Controllers/ContentController.php index eebac012..7f251d3d 100644 --- a/app/Http/Controllers/ContentController.php +++ b/app/Http/Controllers/ContentController.php @@ -26,16 +26,16 @@ class ContentController extends Controller { public function getTracks() { - return View::make('shared.null'); + return view('shared.null'); } public function getAlbums() { - return View::make('shared.null'); + return view('shared.null'); } public function getPlaylist() { - return View::make('shared.null'); + return view('shared.null'); } } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index b2836df0..170b76d1 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -26,6 +26,6 @@ class HomeController extends Controller { public function getIndex() { - return View::make('home.index'); + return view('home.index'); } } diff --git a/app/Http/Controllers/ImagesController.php b/app/Http/Controllers/ImagesController.php index fc93d29b..e9a6aba9 100644 --- a/app/Http/Controllers/ImagesController.php +++ b/app/Http/Controllers/ImagesController.php @@ -33,24 +33,24 @@ class ImagesController extends Controller $coverType = Image::getImageTypeFromName($type); if ($coverType == null) { - App::abort(404); + abort(404); } $image = Image::find($id); if (! $image) { - App::abort(404); + abort(404); } - $response = Response::make('', 200); + $response = response('', 200); $filename = $image->getFile($coverType['id']); if (! is_file($filename)) { $redirect = url('/images/icons/profile_'.Image::$ImageTypes[$coverType['id']]['name'].'.png'); - return Redirect::to($redirect); + return redirect($redirect); } - if (Config::get('app.sendfile')) { + if (config('app.sendfile')) { $response->header('X-Sendfile', $filename); } else { $response->header('X-Accel-Redirect', $filename); diff --git a/app/Http/Controllers/NotificationsController.php b/app/Http/Controllers/NotificationsController.php index 83d1fa8a..19081f73 100644 --- a/app/Http/Controllers/NotificationsController.php +++ b/app/Http/Controllers/NotificationsController.php @@ -68,6 +68,6 @@ class NotificationsController extends Controller public function getEmailUnsubscribePage() { - return View::make('shared.null'); + return view('shared.null'); } } diff --git a/app/Http/Controllers/PlaylistsController.php b/app/Http/Controllers/PlaylistsController.php index 0d792fd7..5c87f28c 100644 --- a/app/Http/Controllers/PlaylistsController.php +++ b/app/Http/Controllers/PlaylistsController.php @@ -33,28 +33,28 @@ class PlaylistsController extends Controller { public function getIndex() { - return View::make('playlists.index'); + return view('playlists.index'); } public function getPlaylist($id, $slug) { $playlist = Playlist::find($id); if (! $playlist || ! $playlist->canView(Auth::user())) { - App::abort(404); + abort(404); } if ($playlist->slug != $slug) { return Redirect::action('PlaylistsController@getPlaylist', [$id, $playlist->slug]); } - return View::make('playlists.show'); + return view('playlists.show'); } public function getShortlink($id) { $playlist = Playlist::find($id); if (! $playlist || ! $playlist->canView(Auth::user())) { - App::abort(404); + abort(404); } return Redirect::action('PlaylistsController@getPlaylist', [$id, $playlist->slug]); @@ -64,7 +64,7 @@ class PlaylistsController extends Controller { $playlist = Playlist::with('tracks', 'tracks.trackFiles', 'user', 'tracks.album')->find($id); if (! $playlist || ! $playlist->canView(Auth::user())) { - App::abort(404); + abort(404); } $format = null; @@ -79,11 +79,11 @@ class PlaylistsController extends Controller } if ($format == null) { - App::abort(404); + abort(404); } if (! $playlist->hasLosslessTracks() && in_array($formatName, Track::$LosslessFormats)) { - App::abort(404); + abort(404); } ResourceLogItem::logItem('playlist', $id, ResourceLogItem::DOWNLOAD, $format['index']); diff --git a/app/Http/Controllers/StatsController.php b/app/Http/Controllers/StatsController.php index bb986372..897cc1d0 100644 --- a/app/Http/Controllers/StatsController.php +++ b/app/Http/Controllers/StatsController.php @@ -26,6 +26,6 @@ class StatsController extends Controller { public function getIndex() { - return View::make('tracks.stats'); + return view('tracks.stats'); } } diff --git a/app/Http/Controllers/TracksController.php b/app/Http/Controllers/TracksController.php index 27fdeb70..3db49e83 100644 --- a/app/Http/Controllers/TracksController.php +++ b/app/Http/Controllers/TracksController.php @@ -35,7 +35,7 @@ class TracksController extends Controller { public function getIndex() { - return View::make('tracks.index'); + return view('tracks.index'); } public function getEmbed($id) @@ -51,7 +51,7 @@ class TracksController extends Controller )->first(); if (! $track || ! $track->canView(Auth::user())) { - App::abort(404); + abort(404); } $userData = [ @@ -75,13 +75,13 @@ class TracksController extends Controller ]; } - return View::make('tracks.embed', ['track' => $track, 'user' => $userData]); + return view('tracks.embed', ['track' => $track, 'user' => $userData]); } public function getOembed(Request $request) { if (! $request->filled('url')) { - App::abort(404); + abort(404); } $parsedUrl = parse_url($request->input('url')); @@ -94,7 +94,7 @@ class TracksController extends Controller ->first(); if (! $track || ! $track->canView(Auth::user())) { - App::abort(404); + abort(404); } $output = [ @@ -117,14 +117,14 @@ class TracksController extends Controller { $track = Track::find($id); if (! $track || ! $track->canView(Auth::user())) { - App::abort(404); + abort(404); } if ($track->slug != $slug) { return Redirect::action('TracksController@getTrack', [$id, $track->slug]); } - return View::make('tracks.show', ['track' => $track]); + return view('tracks.show', ['track' => $track]); } public function getEdit($id, $slug) @@ -136,7 +136,7 @@ class TracksController extends Controller { $track = Track::find($id); if (! $track || ! $track->canView(Auth::user())) { - App::abort(404); + abort(404); } return Redirect::action('TracksController@getTrack', [$id, $track->slug]); @@ -146,21 +146,21 @@ class TracksController extends Controller { $track = Track::find($id); if (! $track || ! $track->canView(Auth::user())) { - App::abort(404); + abort(404); } $trackFile = TrackFile::findOrFailByExtension($track->id, $extension); - $response = Response::make('', 200); + $response = response('', 200); $filename = $trackFile->getFile(); if (! file_exists($filename)) { - App::abort(418); + abort(418); } ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $trackFile->getFormat()['index']); - if (Config::get('app.sendfile')) { + if (config('app.sendfile')) { $response->header('X-Sendfile', $filename); } else { $response->header('X-Accel-Redirect', $filename); @@ -183,16 +183,16 @@ class TracksController extends Controller { $track = Track::find($id); if (! $track || ! $track->canView(Auth::user())) { - App::abort(404); + abort(404); } $trackFile = TrackFile::findOrFailByExtension($track->id, $extension); ResourceLogItem::logItem('track', $id, ResourceLogItem::DOWNLOAD, $trackFile->getFormat()['index']); - $response = Response::make('', 200); + $response = response('', 200); $filename = $trackFile->getFile(); - if (Config::get('app.sendfile')) { + if (config('app.sendfile')) { $response->header('X-Sendfile', $filename); $response->header( 'Content-Disposition', diff --git a/app/Http/Controllers/UploaderController.php b/app/Http/Controllers/UploaderController.php index 1eed0e09..3a5e1943 100644 --- a/app/Http/Controllers/UploaderController.php +++ b/app/Http/Controllers/UploaderController.php @@ -26,6 +26,6 @@ class UploaderController extends Controller { public function getIndex() { - return View::make('shared.null'); + return view('shared.null'); } } diff --git a/app/Jobs/EncodeTrackFile.php b/app/Jobs/EncodeTrackFile.php index a37eeb34..3b2b5cb6 100644 --- a/app/Jobs/EncodeTrackFile.php +++ b/app/Jobs/EncodeTrackFile.php @@ -145,7 +145,7 @@ class EncodeTrackFile extends Job implements ShouldQueue // Insert the expiration time for cached tracks if ($this->isExpirable && $this->trackFile->is_cacheable) { - $this->trackFile->expires_at = Carbon::now()->addMinutes(Config::get('ponyfm.track_file_cache_duration')); + $this->trackFile->expires_at = Carbon::now()->addMinutes(config('ponyfm.track_file_cache_duration')); $this->trackFile->save(); } diff --git a/app/Library/Assets.php b/app/Library/Assets.php index 180ec39b..93179b3d 100644 --- a/app/Library/Assets.php +++ b/app/Library/Assets.php @@ -32,14 +32,14 @@ class Assets } foreach ($scripts as $filename) { - if (Config::get('app.debug') && $filename !== 'templates.js') { + if (config('app.debug') && $filename !== 'templates.js') { $scriptTags .= ""; } else { $scriptTags .= ""; } } - if (Config::get('app.debug')) { + if (config('app.debug')) { $scriptTags .= ''; } @@ -48,7 +48,7 @@ class Assets public static function styleIncludes($area = 'app') { - if (! Config::get('app.debug')) { + if (! config('app.debug')) { return ''; diff --git a/app/Library/File.php b/app/Library/File.php index ff86de63..164ce99b 100644 --- a/app/Library/File.php +++ b/app/Library/File.php @@ -15,7 +15,7 @@ class File extends \Illuminate\Support\Facades\File $name = basename($path); } - $response = Response::make(static::get($path)); + $response = response(static::get($path)); $response->header('Content-Type', $mime); $response->header('Content-Disposition', 'inline; filename="'.$name.'"'); diff --git a/app/Library/Notifications/Drivers/NativeDriver.php b/app/Library/Notifications/Drivers/NativeDriver.php index ba0008ec..5920ed13 100644 --- a/app/Library/Notifications/Drivers/NativeDriver.php +++ b/app/Library/Notifications/Drivers/NativeDriver.php @@ -39,9 +39,9 @@ class NativeDriver extends AbstractDriver */ private function pushNotifications(Activity $activity, $recipients) { - if (Config::get('ponyfm.gcm_key') != 'default') { + if (config('ponyfm.gcm_key') != 'default') { $apiKeys = [ - 'GCM' => Config::get('ponyfm.gcm_key'), + 'GCM' => config('ponyfm.gcm_key'), ]; $webPush = new WebPush($apiKeys); diff --git a/app/Models/Album.php b/app/Models/Album.php index 3c902b0b..b8b0b8a6 100644 --- a/app/Models/Album.php +++ b/app/Models/Album.php @@ -302,7 +302,7 @@ class Album extends Model implements Searchable, Commentable, Favouritable { $dir = (string) (floor($this->id / 100) * 100); - return \Config::get('ponyfm.files_directory').'/tracks/'.$dir; + return config('ponyfm.files_directory').'/tracks/'.$dir; } public function getDates() diff --git a/app/Models/Image.php b/app/Models/Image.php index 0e85dda4..d8c0de3f 100644 --- a/app/Models/Image.php +++ b/app/Models/Image.php @@ -190,7 +190,7 @@ class Image extends Model { $dir = (string) (floor($this->id / 100) * 100); - return Config::get('ponyfm.files_directory').'/images/'.$dir; + return config('ponyfm.files_directory').'/images/'.$dir; } public function ensureDirectoryExists() diff --git a/app/Models/Track.php b/app/Models/Track.php index ecae76bd..c4729972 100644 --- a/app/Models/Track.php +++ b/app/Models/Track.php @@ -607,8 +607,8 @@ class Track extends Model implements Searchable, Commentable, Favouritable ], 'streams' => [ 'mp3' => $track->getStreamUrl('MP3'), - 'aac' => (! Config::get('app.debug') || is_file($track->getFileFor('AAC'))) ? $track->getStreamUrl('AAC') : null, - 'ogg' => (Config::get('app.debug') || is_file($track->getFileFor('OGG Vorbis'))) ? $track->getStreamUrl('OGG Vorbis') : null, + 'aac' => (! config('app.debug') || is_file($track->getFileFor('AAC'))) ? $track->getStreamUrl('AAC') : null, + 'ogg' => (config('app.debug') || is_file($track->getFileFor('OGG Vorbis'))) ? $track->getStreamUrl('OGG Vorbis') : null, ], 'user_data' => $userData, 'permissions' => [ @@ -963,7 +963,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable { $dir = (string) (floor($this->id / 100) * 100); - return \Config::get('ponyfm.files_directory').'/tracks/'.$dir; + return config('ponyfm.files_directory').'/tracks/'.$dir; } public function getDates() @@ -1037,7 +1037,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable */ public function getTemporarySourceFileForVersion(int $version):string { - return Config::get('ponyfm.files_directory').'/queued-tracks/'.$this->id.'v'.$version; + return config('ponyfm.files_directory').'/queued-tracks/'.$this->id.'v'.$version; } /** diff --git a/app/Models/TrackFile.php b/app/Models/TrackFile.php index 17a91196..a5a3f425 100644 --- a/app/Models/TrackFile.php +++ b/app/Models/TrackFile.php @@ -96,7 +96,7 @@ class TrackFile extends Model { $track = Track::find($trackId); if (! $track) { - App::abort(404); + abort(404); } // find the extension's format @@ -108,7 +108,7 @@ class TrackFile extends Model } } if ($requestedFormatName === null) { - App::abort(404); + abort(404); } $trackFile = static:: @@ -119,7 +119,7 @@ class TrackFile extends Model ->first(); if ($trackFile === null) { - App::abort(404); + abort(404); } else { return $trackFile; } @@ -165,7 +165,7 @@ class TrackFile extends Model { $dir = (string) (floor($this->track_id / 100) * 100); - return \Config::get('ponyfm.files_directory').'/tracks/'.$dir; + return config('ponyfm.files_directory').'/tracks/'.$dir; } public function getFile() diff --git a/app/Traits/IndexedInElasticsearchTrait.php b/app/Traits/IndexedInElasticsearchTrait.php index def34c28..38a932dc 100644 --- a/app/Traits/IndexedInElasticsearchTrait.php +++ b/app/Traits/IndexedInElasticsearchTrait.php @@ -62,7 +62,7 @@ trait IndexedInElasticsearchTrait private function getElasticsearchParameters(bool $includeBody = true) { $parameters = [ - 'index' => Config::get('ponyfm.elasticsearch_index'), + 'index' => config('ponyfm.elasticsearch_index'), 'type' => $this->elasticsearchType, 'id' => $this->id, ]; @@ -95,7 +95,7 @@ trait IndexedInElasticsearchTrait */ public function updateElasticsearchEntry() { - $job = (new UpdateSearchIndexForEntity($this))->onQueue(Config::get('ponyfm.indexing_queue')); + $job = (new UpdateSearchIndexForEntity($this))->onQueue(config('ponyfm.indexing_queue')); $this->dispatch($job); }