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