koel/app/Http/Controllers/V6/API/ArtistController.php

34 lines
852 B
PHP
Raw Normal View History

2022-06-10 10:47:46 +00:00
<?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 Illuminate\Contracts\Auth\Authenticatable;
class ArtistController extends Controller
{
/** @param User $user */
2022-07-27 15:32:36 +00:00
public function __construct(private ArtistRepository $artistRepository, private ?Authenticatable $user)
{
2022-06-10 10:47:46 +00:00
}
public function index()
{
$pagination = Artist::withMeta($this->user)
->isStandard()
->orderBy('artists.name')
->simplePaginate(21);
return ArtistResource::collection($pagination);
}
public function show(Artist $artist)
{
return ArtistResource::make($this->artistRepository->getOne($artist->id, $this->user));
2022-06-10 10:47:46 +00:00
}
}