Example #1
0
 /**
  * Applies $model->orderBy clause if its present and no ordering has been set on the query
  *
  * @return $this
  */
 public function builderOrderBy()
 {
     if ($this->model->getOrderBy() && !$this->query->orders) {
         if (array_key_exists(0, $this->model->getOrderBy())) {
             throw new \Exception(get_class($this->model) . '->orderBy property must be an associated array comprised of $field => $direction values');
         }
         foreach ($this->model->getOrderBy() as $field => $direction) {
             $this->query->orderBy($field, $direction);
         }
     }
     return $this;
 }
 function testSetNewBuilder()
 {
     \Innoscience\Eloquental\Eloquental::setBuilder(null);
     TestPost::get();
 }