Example #1
0
 /**
  * Prepare and fetch all rows
  */
 protected function _rows()
 {
     if (empty($this->_rowsPrepared)) {
         try {
             if (!empty($this->_entity)) {
                 $repo = $this->_repo();
                 $repoMethod = $this->_v('repo.method', 'count');
                 if ($repoMethod == 'count') {
                     if ($this->_entity->hasSoftDelete()) {
                         $this->_rows = $repo->withTrashed()->count($this->_repoFilters, $this->_repoJoins);
                     } else {
                         $this->_rows = $repo->count($this->_repoFilters, $this->_repoJoins);
                     }
                 }
             }
             $this->_rowsPrepared = true;
         } catch (\Zbase\Exceptions\RuntimeException $e) {
             if (zbase_in_dev($e)) {
                 dd($e);
             } else {
                 zbase_abort(500);
             }
         }
     }
 }
Example #2
0
 /**
  * Prepare and fetch all rows
  */
 protected function _rows()
 {
     if (empty($this->_rowsPrepared)) {
         try {
             $datas = $this->_v('datas', null);
             if (!empty($datas)) {
                 $this->_rows = $datas;
                 $this->_rowsPrepared = true;
                 return;
             }
             if (!empty($this->_entity)) {
                 if ($this->isQueryOnLoad()) {
                     $repo = $this->_repo();
                     $entityObject = $this->entityObject();
                     if ($entityObject->hasSoftDelete() && $this->nodeIncludeTrashed()) {
                         $this->_rows = $repo->setDebug(false)->withTrashed()->all($this->_repoSelects, $this->_repoFilters, $this->_repoSorts, $this->_repoJoins, $this->_repoPerPage);
                     } else {
                         $this->_rows = $repo->setDebug(false)->all($this->_repoSelects, $this->_repoFilters, $this->_repoSorts, $this->_repoJoins, $this->_repoPerPage);
                     }
                     // dd($this->_repoFilters, $this->_rows);
                 }
             }
             $this->_rowsPrepared = true;
         } catch (\Zbase\Exceptions\RuntimeException $e) {
             if (zbase_in_dev($e)) {
                 dd($e);
             } else {
                 zbase_abort(500);
             }
         }
     }
 }