예제 #1
0
 /**
  * Saving inserted or updated data
  */
 public function save()
 {
     $data = $this->getData();
     if (!$this->currentId) {
         $config = $this->config();
         $config->last_id++;
         $this->set->id = $config->last_id;
         array_push($data, $this->set);
         Helpers\Config::table($this->name)->put($config);
     } else {
         $this->set->id = $this->currentId;
         $data[$this->currentKey] = $this->set;
     }
     Helpers\Data::table($this->name)->put($data);
     //         $this->setFields();
 }
예제 #2
0
 /**
  * Checking that relation between tables exists
  * @param string $local local table
  * @param string $foreign related table
  * @return bool relation exists
  * @throws LazerException
  */
 public static function relation($local, $foreign)
 {
     $relations = Config::table($local)->relations();
     if (isset($relations->{$foreign})) {
         return true;
     }
     throw new LazerException('Relation "' . $local . '" to "' . $foreign . '" doesn\'t exist');
 }
예제 #3
0
 /**
  * Inserts relation data to config file
  * @param string $from Local table
  * @param string $to Related table
  */
 protected function deleteRelationData($from, $to)
 {
     $config = Config::table($from);
     $content = $config->get();
     unset($content->relations->{$to});
     $config->put($content);
 }