Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

koel/koel

16858 stars
2 code files
View koel/koel on GitHub

app/Traits/CanFilterByUser.php

Open in GitHub
use Illuminate\Database\Eloquent\Builder;
 
trait CanFilterByUser
{
public function scopeByCurrentUser(Builder $query): Builder
{
return $query->where('user_id', auth()->user()->id);
}
}

app/Repositories/PlaylistRepository.php

Open in GitHub
use App\Repositories\Traits\ByCurrentUser;
use Illuminate\Support\Collection;
 
class PlaylistRepository extends AbstractRepository
{
use ByCurrentUser;
 
public function getAllByCurrentUser(): Collection
{
return $this->byCurrentUser()->orderBy('name')->get();
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.