示例#1
0
 /**
  * Retrieve author by id
  * 
  * @param  AuthorId $authorId
  * @return Author
  */
 public function findById(MediaDomainModels\AuthorId $authorId)
 {
     $author = $this->model->find($authorId->value());
     return $this->toDomainModel($author);
 }
示例#2
0
 /**
  * Retreive library shared to user
  * 
  * @param  AuthorId $authorId
  * @return array
  */
 public function sharedToAuthor(MediaDomainModels\AuthorId $authorId)
 {
     $eloquentLibraries = $this->model->whereHas('users', function ($query) use($authorId) {
         $query->where('user_id', $authorId->value());
     })->get();
     $libraries = [];
     foreach ($eloquentLibraries as $library) {
         $libraries[] = $this->toDomainModel($library);
     }
     return $libraries;
 }