protected function relations($model, $foreignKeyIds)
    {
        $relations = $model->getSoftCascade();

        if (empty($relations)) {
            return;
        }

        foreach ($relations as $relation) {
            extract($this->relationResolver($relation));
            $this->validateRelation($model, $relation);

            $modelRelation = $model->$relation();

            /**
             * Maintains compatibility fot get foreign key name on laravel old and new methods.
             *
             * @link https://github.com/laravel/framework/issues/20869
             */
            $fnUseGetForeignKey = array_intersect($this->fnGetForeignKey, get_class_methods($modelRelation));
            $fnUseGetForeignKey = reset($fnUseGetForeignKey);

            //Get foreign key and foreign key ids
            $foreignKeyUse = $modelRelation->{$fnUseGetForeignKey}();
            $foreignKeyIdsUse = $foreignKeyIds;

            //Many to many relations need to get related ids and related local key
            if ($modelRelation instanceof BelongsToMany) {
                extract($this->getBelongsToManyData($modelRelation, $foreignKeyUse, $foreignKeyIds));
            } elseif ($modelRelation instanceof MorphOneOrMany) {
                extract($this->getMorphManyData($modelRelation, $foreignKeyIds));
            }

            $affectedRows = $this->affectedRows($modelRelation, $foreignKeyUse, $foreignKeyIdsUse);

            if ($action === 'restrict' && $affectedRows > 0) {
                DB::rollBack(); //Rollback the transaction before throw exception
                throw (new SoftCascadeRestrictedException())->setModel(get_class($modelRelation->getModel()), $foreignKeyUse, $foreignKeyIdsUse->toArray());
            }

            $this->execute($modelRelation, $foreignKeyUse, $foreignKeyIdsUse, $affectedRows);
        }
    }
protected function relations($model, $foreignKeyIds)
    {
        $relations = $model->getSoftCascade();

        if (empty($relations)) {
            return;
        }

        foreach ($relations as $relation) {
            extract($this->relationResolver($relation));
            $this->validateRelation($model, $relation);

            $modelRelation = $model->$relation();

            /**
             * Maintains compatibility fot get foreign key name on laravel old and new methods.
             *
             * @link https://github.com/laravel/framework/issues/20869
             */
            $fnUseGetForeignKey = array_intersect($this->fnGetForeignKey, get_class_methods($modelRelation));
            $fnUseGetForeignKey = reset($fnUseGetForeignKey);

            //Get foreign key and foreign key ids
            $foreignKeyUse = $modelRelation->{$fnUseGetForeignKey}();
            $foreignKeyIdsUse = $foreignKeyIds;

            //Many to many relations need to get related ids and related local key
            if ($modelRelation instanceof BelongsToMany) {
                extract($this->getBelongsToManyData($modelRelation, $foreignKeyUse, $foreignKeyIds));
            } elseif ($modelRelation instanceof MorphOneOrMany) {
                extract($this->getMorphManyData($modelRelation, $foreignKeyIds));
            }

            $affectedRows = $this->affectedRows($modelRelation, $foreignKeyUse, $foreignKeyIdsUse);

            if ($action === 'restrict' && $affectedRows > 0) {
                DB::rollBack(); //Rollback the transaction before throw exception
                throw (new SoftCascadeRestrictedException())->setModel(get_class($modelRelation->getModel()), $foreignKeyUse, $foreignKeyIdsUse->toArray());
            }

            $this->execute($modelRelation, $foreignKeyUse, $foreignKeyIdsUse, $affectedRows);
        }
    }
protected function relations ( $ model , $ foreignKeyIds ) { $ relations = $ model -> getSoftCascade ( ) ; if ( empty ( $ relations ) ) { return ; } foreach ( $ relations as $ relation ) { extract ( $ this -> relationResolver ( $ relation ) ) ; $ this -> validateRelation ( $ model , $ relation ) ; $ modelRelation = $ model -> $ relation ( ) ; /**
             * Maintains compatibility fot get foreign key name on laravel old and new methods.
             *
             * @link https://github.com/laravel/framework/issues/20869
             */ $ fnUseGetForeignKey = array_intersect ( $ this -> fnGetForeignKey , get_class_methods ( $ modelRelation ) ) ; $ fnUseGetForeignKey = reset ( $ fnUseGetForeignKey ) ; //Get foreign key and foreign key ids $ foreignKeyUse = $ modelRelation -> { $ fnUseGetForeignKey } ( ) ; $ foreignKeyIdsUse = $ foreignKeyIds ; //Many to many relations need to get related ids and related local key if ( $ modelRelation instanceof BelongsToMany ) { extract ( $ this -> getBelongsToManyData ( $ modelRelation , $ foreignKeyUse , $ foreignKeyIds ) ) ; } elseif ( $ modelRelation instanceof MorphOneOrMany ) { extract ( $ this -> getMorphManyData ( $ modelRelation , $ foreignKeyIds ) ) ; } $ affectedRows = $ this -> affectedRows ( $ modelRelation , $ foreignKeyUse , $ foreignKeyIdsUse ) ; if ( $ action === 'restrict' && $ affectedRows > 0 ) { DB :: rollBack ( ) ; //Rollback the transaction before throw exception throw ( new SoftCascadeRestrictedException ( ) ) -> setModel ( get_class ( $ modelRelation -> getModel ( ) ) , $ foreignKeyUse , $ foreignKeyIdsUse -> toArray ( ) ) ; } $ this -> execute ( $ modelRelation , $ foreignKeyUse , $ foreignKeyIdsUse , $ affectedRows ) ; } }
Iterate over the relations.

@param Illuminate\Database\Eloquent\Model $model
@param array                              $foreignKeyIds
@param array                              $foreignKeyIds

@return mixed
Iterate over the relations .