コード例 #1
0
 /**
  * @return $this|mixed
  */
 public function presenter()
 {
     if ($this->hasPresenter()) {
         return $this->presenter->present($this);
     }
     return $this;
 }
コード例 #2
0
 /**
  * Parse a collection of objects.
  *
  * @param Model|array|Paginator|Collection $result
  * @return mixed
  * @throws NotFoundError
  */
 public function parseResult($result)
 {
     $this->logSqlQueries();
     if ($result == null) {
         throw new NotFoundError($this->getMessage('not_found'));
     }
     if ($this->presenter instanceof PresenterInterface) {
         if ($result instanceof Collection || $result instanceof LengthAwarePaginator) {
             $result->each(function ($model) {
                 if ($model instanceof Presentable) {
                     $model->setPresenter($this->presenter);
                 }
                 return $model;
             });
         } elseif ($result instanceof Presentable) {
             $result = $result->setPresenter($this->presenter);
         }
         if (!$this->skipPresenter) {
             return $this->presenter->present($result);
         }
     }
     return $result;
 }