public function insertModels(Models $models)
    {
        foreach ($models as $model) {
            $this->dispatchBeforeEvent($model, Event::INSERT);
            $this->dispatchBeforeEvent($model, Event::SAVE);
        }

        $this->insertAll()->executeModels($models);

        foreach ($models as $model) {
            $model
                ->resetOriginals()
                ->setState(State::SAVED);

            $this->dispatchAfterEvent($model, Event::INSERT);
            $this->dispatchAfterEvent($model, Event::SAVE);
        }

        return $this;
    }
public function insertModels(Models $models)
    {
        foreach ($models as $model) {
            $this->dispatchBeforeEvent($model, Event::INSERT);
            $this->dispatchBeforeEvent($model, Event::SAVE);
        }

        $this->insertAll()->executeModels($models);

        foreach ($models as $model) {
            $model
                ->resetOriginals()
                ->setState(State::SAVED);

            $this->dispatchAfterEvent($model, Event::INSERT);
            $this->dispatchAfterEvent($model, Event::SAVE);
        }

        return $this;
    }
public function insertModels ( Models $ models ) { foreach ( $ models as $ model ) { $ this -> dispatchBeforeEvent ( $ model , Event :: INSERT ) ; $ this -> dispatchBeforeEvent ( $ model , Event :: SAVE ) ; } $ this -> insertAll ( ) -> executeModels ( $ models ) ; foreach ( $ models as $ model ) { $ model -> resetOriginals ( ) -> setState ( State :: SAVED ) ; $ this -> dispatchAfterEvent ( $ model , Event :: INSERT ) ; $ this -> dispatchAfterEvent ( $ model , Event :: SAVE ) ; } return $ this ; }
Call all the events associated with model insertion. Perform the insertion itself.

@param  Models           $models
@return Repo $this
Call all the events associated with model insertion . Perform the insertion itself .