mirror of
https://github.com/koel/koel
synced 2024-11-28 15:00:42 +00:00
Some refactors
This commit is contained in:
parent
2e59ab0bb1
commit
fb49cd6fb1
2 changed files with 3 additions and 6 deletions
|
@ -130,11 +130,11 @@ class Interaction extends Model
|
|||
*/
|
||||
public static function batchUnlike(array $songIds, User $user)
|
||||
{
|
||||
foreach (self::whereIn('song_id', $songIds)->whereUserId($user->id)->get() as $interaction) {
|
||||
self::whereIn('song_id', $songIds)->whereUserId($user->id)->get()->each(function ($interaction) {
|
||||
$interaction->liked = false;
|
||||
$interaction->save();
|
||||
|
||||
event(new SongLikeToggled($interaction));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,10 +244,7 @@ class Song extends Model
|
|||
*/
|
||||
public static function getFavorites(User $user, $toArray = false)
|
||||
{
|
||||
$songs = Interaction::where([
|
||||
'user_id' => $user->id,
|
||||
'liked' => true,
|
||||
])
|
||||
$songs = Interaction::whereUserIdAndLike($user->id, true)
|
||||
->with('song')
|
||||
->get()
|
||||
->pluck('song');
|
||||
|
|
Loading…
Reference in a new issue