/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->setUpFilesystem(); $this->object = Config::table('users'); }
/** * 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'); }