2016-06-04 13:42:12 +00:00
|
|
|
<?php
|
|
|
|
|
2020-09-07 20:43:23 +00:00
|
|
|
namespace App\Http\Controllers\Download;
|
2016-06-04 13:42:12 +00:00
|
|
|
|
2022-07-29 06:47:10 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Models\User;
|
2018-08-29 06:15:11 +00:00
|
|
|
use App\Repositories\InteractionRepository;
|
2018-08-22 20:25:01 +00:00
|
|
|
use App\Services\DownloadService;
|
2022-07-29 06:47:10 +00:00
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
2016-06-04 13:42:12 +00:00
|
|
|
|
|
|
|
class FavoritesController extends Controller
|
|
|
|
{
|
2022-07-29 06:47:10 +00:00
|
|
|
/** @param User $user */
|
|
|
|
public function __construct(
|
|
|
|
private DownloadService $downloadService,
|
|
|
|
private InteractionRepository $interactionRepository,
|
|
|
|
private ?Authenticatable $user
|
|
|
|
) {
|
2018-08-22 20:25:01 +00:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:47:10 +00:00
|
|
|
public function show()
|
2016-06-04 13:42:12 +00:00
|
|
|
{
|
2022-07-29 06:47:10 +00:00
|
|
|
$songs = $this->interactionRepository->getUserFavorites($this->user);
|
2018-08-18 11:51:52 +00:00
|
|
|
|
|
|
|
return response()->download($this->downloadService->from($songs));
|
2016-06-04 13:42:12 +00:00
|
|
|
}
|
|
|
|
}
|