Refactor useLastfm config

This commit is contained in:
An Phan 2016-06-05 12:37:03 +08:00
parent bec05931b3
commit 27b44ec79c
3 changed files with 15 additions and 1 deletions

View file

@ -8,6 +8,7 @@ use App\Models\Interaction;
use App\Models\Playlist; use App\Models\Playlist;
use App\Models\Setting; use App\Models\Setting;
use App\Models\User; use App\Models\User;
use Lastfm;
class DataController extends Controller class DataController extends Controller
{ {
@ -32,7 +33,7 @@ class DataController extends Controller
'interactions' => Interaction::byCurrentUser()->get(), 'interactions' => Interaction::byCurrentUser()->get(),
'users' => auth()->user()->is_admin ? User::all() : [], 'users' => auth()->user()->is_admin ? User::all() : [],
'currentUser' => auth()->user(), 'currentUser' => auth()->user(),
'useLastfm' => env('LASTFM_API_KEY') && env('LASTFM_API_SECRET'), 'useLastfm' => Lastfm::used(),
'allowDownload' => env('ALLOW_DOWNLOAD', true), 'allowDownload' => env('ALLOW_DOWNLOAD', true),
'cdnUrl' => app()->staticUrl(), 'cdnUrl' => app()->staticUrl(),
'currentVersion' => Application::VERSION, 'currentVersion' => Application::VERSION,

View file

@ -60,5 +60,8 @@ Route::group(['prefix' => 'api', 'namespace' => 'API'], function () {
Route::get('playlist/{playlist}', 'PlaylistController@download'); Route::get('playlist/{playlist}', 'PlaylistController@download');
Route::get('favorites', 'FavoritesController@download'); Route::get('favorites', 'FavoritesController@download');
}); });
// Info routes
//if (Lastfm::used())
}); });
}); });

View file

@ -40,6 +40,16 @@ class Lastfm extends RESTfulService
); );
} }
/**
* Determine if our application is using Last.fm.
*
* @return bool
*/
public function used()
{
return env('LASTFM_API_KEY') && env('LASTFM_API_SECRET');
}
/** /**
* Determine if Last.fm integration is enabled. * Determine if Last.fm integration is enabled.
* *