/** * @covers Lazer\Classes\Helpers\Config::lastId */ public function testLastId() { $this->assertInternalType('integer', $this->object->lastId()); }
/** * Inserts relation data to config file * @param string $from Local table * @param string $to Related table * @param string $type Relation type * @param array $keys Relationed keys */ protected function deleteRelationData($from, $to) { $config = Config::table($from); $content = $config->get(); unset($content->relations->{$to}); $config->put($content); }
/** * 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(); }
/** * 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'); }