mirror of
https://github.com/koel/koel
synced 2025-02-26 12:17:12 +00:00
32 lines
658 B
PHP
32 lines
658 B
PHP
<?php
|
|
|
|
namespace App\Repositories;
|
|
|
|
use App\Models\Interaction;
|
|
use App\Models\User;
|
|
use App\Repositories\Traits\ByCurrentUser;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class InteractionRepository extends AbstractRepository
|
|
{
|
|
use ByCurrentUser;
|
|
|
|
public function getModelClass(): string
|
|
{
|
|
return Interaction::class;
|
|
}
|
|
|
|
/**
|
|
* Get all songs favorited by a user.
|
|
*/
|
|
public function getUserFavorites(User $user): Collection
|
|
{
|
|
return $this->model->where([
|
|
'user_id' => $user->id,
|
|
'like' => true,
|
|
])
|
|
->with('song')
|
|
->get()
|
|
->pluck('song');
|
|
}
|
|
}
|