src/Collection.php
public function set($models)
    {
        if ($models instanceof ActiveRecord) {
            $models = [$models];
        }

        $first = reset($models);
        if ($first === false) {
            return $this;
        }
        $this->first = $first;

        $this->formName = $first->formName();
        $this->model    = $this->setModel($first);
        $this->models   = $models;

        if ($this->checkConsistency && !$this->isConsistent()) {
            throw new InvalidValueException('Models are not objects of same class or not follow same operation');
        }

        return $this;
    }
public function set($models)
    {
        if ($models instanceof ActiveRecord) {
            $models = [$models];
        }

        $first = reset($models);
        if ($first === false) {
            return $this;
        }
        $this->first = $first;

        $this->formName = $first->formName();
        $this->model    = $this->setModel($first);
        $this->models   = $models;

        if ($this->checkConsistency && !$this->isConsistent()) {
            throw new InvalidValueException('Models are not objects of same class or not follow same operation');
        }

        return $this;
    }
public function set ( $ models ) { if ( $ models instanceof ActiveRecord ) { $ models = [ $ models ] ; } $ first = reset ( $ models ) ; if ( $ first === false ) { return $ this ; } $ this -> first = $ first ; $ this -> formName = $ first -> formName ( ) ; $ this -> model = $ this -> setModel ( $ first ) ; $ this -> models = $ models ; if ( $ this -> checkConsistency && ! $ this -> isConsistent ( ) ) { throw new InvalidValueException ( 'Models are not objects of same class or not follow same operation' ) ; } return $ this ; }
Sets the array of AR models to the collection.
@param array|ActiveRecord $models - array of AR Models or a single model
@return $this
Sets the array of AR models to the collection .