mirror of
https://github.com/koel/koel
synced 2024-12-21 01:53:11 +00:00
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\V6\API;
|
||
|
|
||
|
use App\Http\Controllers\API\Controller;
|
||
|
use App\Http\Resources\ArtistResource;
|
||
|
use App\Models\Artist;
|
||
|
use App\Models\User;
|
||
|
use App\Repositories\ArtistRepository;
|
||
|
use App\Services\MediaInformationService;
|
||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||
|
|
||
|
class ArtistController extends Controller
|
||
|
{
|
||
|
/** @param User $user */
|
||
|
public function __construct(
|
||
|
private ArtistRepository $artistRepository,
|
||
|
private MediaInformationService $informationService,
|
||
|
private ?Authenticatable $user
|
||
|
) {
|
||
|
}
|
||
|
|
||
|
public function index()
|
||
|
{
|
||
|
$pagination = Artist::withMeta($this->user)
|
||
|
->isStandard()
|
||
|
->orderBy('artists.name')
|
||
|
->simplePaginate(21);
|
||
|
|
||
|
return ArtistResource::collection($pagination);
|
||
|
}
|
||
|
|
||
|
public function show(Artist $artist)
|
||
|
{
|
||
|
$artist = $this->artistRepository->getOne($artist->id, $this->user);
|
||
|
$artist->information = $this->informationService->getArtistInformation($artist);
|
||
|
|
||
|
return ArtistResource::make($artist);
|
||
|
}
|
||
|
}
|