Example #1
0
 public function create(array $data = [])
 {
     $data = array_merge($this->model->getRows(), $this->getValidData($data));
     if (count($data) === 0) {
         throw new ModelException('Not valid columns found to update.');
     }
     $id = $this->query->insert($data);
     if ($id) {
         $this->model->mergeRows($data);
         $this->model->{$this->model->getPrimary()} = $id;
         return $this->model;
     }
     return false;
 }