Пример #1
0
 function __construct($name, $params = [])
 {
     parent::__construct($name, $params);
     $this->prefix = $name;
     $this->bundles = new Collection();
     return $this;
 }
Пример #2
0
 function __construct($name, $params = [])
 {
     parent::__construct($name, $params);
     $this->keys = new Collection();
     $this->models = new Collection();
     $this->models->set('owner', $this->owner);
     $this->owner->addAssociation($this);
     switch ($this->type) {
         case 'belongsTo':
             $this->models->set('child', $this->owner);
             $this->models->set('parent', $this->target);
             $this->addKey('local', $this->owner->fields->get($this->ownerKey));
             $this->addKey('parent', $this->target->fields->get($this->targetKey));
             $this->owner->fields->get($this->ownerKey)->parent = $this->target;
             break;
         case 'belongsToMany':
             $this->pivotOwnerBelongsTo = $this->pivot->associations->get($this->owner->name);
             $this->pivotTargetBelongsTo = $this->pivot->associations->get($this->target->name);
             $this->models->set('child', $this->owner);
             $this->models->set('parent', $this->target);
             $this->models->set('pivot', $this->pivot);
             $this->addKey('local', $this->owner->fields->get($this->ownerKey));
             $this->addKey('parent', $this->target->fields->get($this->targetKey));
             $this->addKey('pivot_local', $this->pivotOwnerBelongsTo->keys('local'));
             $this->addKey('pivot_parent', $this->pivotTargetBelongsTo->keys('local'));
             break;
         case 'hasMany':
             $this->models->set('child', $this->target);
             $this->models->set('parent', $this->owner);
             $this->addKey('local', $this->owner->fields->get($this->ownerKey));
             $this->addKey('foreign', $this->target->fields->get($this->targetKey));
             break;
         case 'hasOne':
             $this->models->set('child', $this->target);
             $this->models->set('parent', $this->owner);
             $this->addKey('local', $this->owner->fields->get($this->ownerKey));
             $this->addKey('foreign', $this->target->fields->get($this->targetKey));
             break;
     }
 }
Пример #3
0
 function __construct($name, $params = [])
 {
     parent::__construct($name, $params);
     $this->models = new Collection();
 }
Пример #4
0
 /**
  * @param string $name
  */
 function __construct($name, $params = [])
 {
     parent::__construct($name, $params);
     $this->fields = new Collection();
     $this->associations = new Collection();
 }