koel/app/Repositories/Traits/ByCurrentUser.php

20 lines
377 B
PHP
Raw Normal View History

2018-08-29 06:15:11 +00:00
<?php
namespace App\Repositories\Traits;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
trait ByCurrentUser
{
private function byCurrentUser(): Builder
{
return $this->model->whereUserId($this->auth->id());
}
public function getAllByCurrentUser(): Collection
{
return $this->byCurrentUser()->get();
}
}