public function runSetup()
 {
     if (isset($this->options['through'])) {
         $junctionModelName = $this->options['through'];
     } else {
         $junctionModelName = Nibii::joinModels($this->setupName, $this->options['model']);
     }
     $this->options['junction_model'] = $junctionModelName;
     $foreignModel = Nibii::load($this->options['model']);
     if ($this->options['foreign_key'] == null) {
         $this->options['foreign_key'] = $foreignModel->getDescription()->getPrimaryKey()[0];
     }
     if ($this->options['local_key'] == null) {
         $this->options['local_key'] = $this->setupPrimaryKey[0];
     }
     if (!isset($this->options['junction_local_key'])) {
         $this->options['junction_local_key'] = Text::singularize($this->setupTable) . '_id';
     }
     if (!isset($this->options['junction_foreign_key'])) {
         $this->options['junction_foreign_key'] = Text::singularize($foreignModel->getTable()) . '_id';
     }
 }
Example #2
0
 public function testTableResolution()
 {
     $users = Nibii::load(Users::class);
     $description = $users->getDescription();
     $this->assertInstanceOf('\\ntentan\\nibii\\ModelDescription', $description);
 }
Example #3
0
 public static function load($name)
 {
     return nibii\Nibii::load($name);
 }