2022-06-10 10:47:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\V6\API;
|
|
|
|
|
2022-07-29 06:47:10 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Resources\AlbumResource;
|
|
|
|
use App\Models\Album;
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Repositories\AlbumRepository;
|
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
|
|
|
|
|
|
|
class AlbumController extends Controller
|
|
|
|
{
|
|
|
|
/** @param User $user */
|
2022-07-08 14:53:04 +00:00
|
|
|
public function __construct(private AlbumRepository $albumRepository, private ?Authenticatable $user)
|
|
|
|
{
|
2022-06-10 10:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$pagination = Album::withMeta($this->user)
|
|
|
|
->isStandard()
|
|
|
|
->orderBy('albums.name')
|
|
|
|
->simplePaginate(21);
|
|
|
|
|
|
|
|
return AlbumResource::collection($pagination);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function show(Album $album)
|
|
|
|
{
|
2022-07-08 14:53:04 +00:00
|
|
|
return AlbumResource::make($this->albumRepository->getOne($album->id, $this->user));
|
2022-06-10 10:47:46 +00:00
|
|
|
}
|
|
|
|
}
|