/** * Get a set of application data. * * @return \Illuminate\Http\JsonResponse */ public function index() { $playlists = Playlist::byCurrentUser()->orderBy('name')->with('songs')->get()->toArray(); // We don't need full song data, just ID's foreach ($playlists as &$playlist) { $playlist['songs'] = array_pluck($playlist['songs'], 'id'); } return response()->json(['artists' => Artist::orderBy('name')->with('albums', with('albums.songs'))->get(), 'settings' => Setting::all()->lists('value', 'key'), 'playlists' => $playlists, 'interactions' => Interaction::byCurrentUser()->get(), 'users' => auth()->user()->is_admin ? User::all() : [], 'user' => auth()->user()]); }
/** * Get a set of application data. * * @return \Illuminate\Http\JsonResponse */ public function index() { $playlists = Playlist::byCurrentUser()->orderBy('name')->with('songs')->get()->toArray(); // We don't need full song data, just ID's foreach ($playlists as &$playlist) { $playlist['songs'] = array_pluck($playlist['songs'], 'id'); } return response()->json(['artists' => Artist::orderBy('name')->with('albums', with('albums.songs'))->get(), 'settings' => auth()->user()->is_admin ? Setting::pluck('value', 'key')->all() : [], 'playlists' => $playlists, 'interactions' => Interaction::byCurrentUser()->get(), 'users' => auth()->user()->is_admin ? User::all() : [], 'currentUser' => auth()->user(), 'useLastfm' => Lastfm::used(), 'useYouTube' => YouTube::enabled(), 'allowDownload' => config('koel.download.allow'), 'cdnUrl' => app()->staticUrl(), 'currentVersion' => Application::VERSION, 'latestVersion' => auth()->user()->is_admin ? app()->getLatestVersion() : Application::VERSION]); }
/** * Get a set of application data. * * @return \Illuminate\Http\JsonResponse */ public function index() { $playlists = Playlist::byCurrentUser()->orderBy('name')->with('songs')->get()->toArray(); // We don't need full song data, just ID's foreach ($playlists as &$playlist) { $playlist['songs'] = array_pluck($playlist['songs'], 'id'); } return response()->json(['artists' => Artist::orderBy('name')->with('albums', with('albums.songs'))->get(), 'settings' => Setting::lists('value', 'key')->all(), 'playlists' => $playlists, 'interactions' => Interaction::byCurrentUser()->get(), 'users' => auth()->user()->is_admin ? User::all() : [], 'currentUser' => auth()->user(), 'useLastfm' => env('LASTFM_API_KEY') && env('LASTFM_API_SECRET'), 'currentVersion' => Application::VERSION, 'latestVersion' => auth()->user()->is_admin ? app()->getLatestVersion() : Application::VERSION]); }
/** * Run the migrations. * * @return void */ public function up() { // This is to fix the auto increment bug caused by 2016_04_16_082627_create_various_artists // Return if the database driver is not MySQL. if (DB::getDriverName() !== 'mysql') { return; } $latestArtist = Artist::orderBy('id', 'DESC')->first(); DB::statement('ALTER TABLE artists AUTO_INCREMENT=' . ($latestArtist->id + 1)); }
/** * Create the "Various Artists". * * @return void */ public function up() { Artist::unguard(); $existingArtist = Artist::find(Artist::VARIOUS_ID); if ($existingArtist) { if ($existingArtist->name === Artist::VARIOUS_NAME) { goto ret; } // There's an existing artist with that special ID, but it's not our Various Artist // We move it to the end of the table. $latestArtist = Artist::orderBy('id', 'DESC')->first(); $existingArtist->id = $latestArtist->id + 1; $existingArtist->save(); } Artist::create(['id' => Artist::VARIOUS_ID, 'name' => Artist::VARIOUS_NAME]); ret: Artist::reguard(); }
/** * Create the "Various Artists". * * @return void */ public function up() { // Make sure modified artists cascade the album's artist_id field. Schema::table('albums', function ($table) { $table->dropForeign('albums_artist_id_foreign'); $table->foreign('artist_id')->references('id')->on('artists')->onUpdate('cascade')->onDelete('cascade'); }); Artist::unguard(); $existingArtist = Artist::find(Artist::VARIOUS_ID); if ($existingArtist) { if ($existingArtist->name === Artist::VARIOUS_NAME) { goto ret; } // There's an existing artist with that special ID, but it's not our Various Artist // We move it to the end of the table. $latestArtist = Artist::orderBy('id', 'DESC')->first(); $existingArtist->id = $latestArtist->id + 1; $existingArtist->save(); } Artist::create(['id' => Artist::VARIOUS_ID, 'name' => Artist::VARIOUS_NAME]); ret: Artist::reguard(); }