Test Setup Failed
Push — master ( e40a57...f3143d )
by Phan
06:47 queued 01:08
created

app/Http/Controllers/API/DataController.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace App\Http\Controllers\API;
4
5
use App\Application;
6
use App\Models\Interaction;
7
use App\Models\Playlist;
8
use App\Models\Setting;
9
use App\Models\User;
10
use Illuminate\Http\JsonResponse;
11
use Illuminate\Http\Request;
12
use iTunes;
13
use Lastfm;
14
use MediaCache;
15
use YouTube;
16
17
class DataController extends Controller
18
{
19
    /**
20
     * Get a set of application data.
21
     *
22
     * @param Request $request
23
     *
24
     * @return JsonResponse
25
     */
26
    public function index(Request $request)
27
    {
28
        $playlists = Playlist::byCurrentUser()->orderBy('name')->with('songs')->get()->toArray();
29
30
        // We don't need full song data, just ID's
31
        foreach ($playlists as &$playlist) {
32
            $playlist['songs'] = array_pluck($playlist['songs'], 'id');
33
        }
34
35
        return response()->json(MediaCache::get() + [
36
            'settings' => $request->user()->is_admin ? Setting::pluck('value', 'key')->all() : [],
37
            'playlists' => $playlists,
38
            'interactions' => Interaction::byCurrentUser()->get(),
0 ignored issues
show
The method byCurrentUser() does not exist on App\Models\Interaction. Did you maybe mean scopeByCurrentUser()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
39
            'users' => $request->user()->is_admin ? User::all() : [],
40
            'currentUser' => $request->user(),
41
            'useLastfm' => Lastfm::used(),
42
            'useYouTube' => YouTube::enabled(),
43
            'useiTunes' => iTunes::used(),
44
            'allowDownload' =>  config('koel.download.allow'),
45
            'supportsTranscoding' => config('koel.streaming.ffmpeg_path') && is_executable(config('koel.streaming.ffmpeg_path')),
46
            'cdnUrl' => app()->staticUrl(),
47
            'currentVersion' => Application::KOEL_VERSION,
48
            'latestVersion' => $request->user()->is_admin ? app()->getLatestVersion() : Application::KOEL_VERSION,
49
        ]);
50
    }
51
}
52