public function unhookSingleModel(
        ResourceSet $sourceResourceSet,
        $sourceEntityInstance,
        ResourceSet $targetResourceSet,
        $targetEntityInstance,
        $navPropName
    ) {
        $relation = $this->isModelHookInputsOk($sourceEntityInstance, $targetEntityInstance, $navPropName);

        // in case the fake 'PrimaryKey' attribute got set inbound for a polymorphic-affected model, flatten it now
        unset($targetEntityInstance->PrimaryKey);

        $changed = false;

        if ($relation instanceof BelongsTo) {
            $relation->dissociate();
            $changed = true;
        } elseif ($relation instanceof BelongsToMany) {
            $relation->detach($targetEntityInstance);
            $changed = true;
        } elseif ($relation instanceof HasOneOrMany) {
            // dig up inverse property name, so we can pass it to unhookSingleModel with source and target elements
            // swapped
            $otherPropName = $this->getMetadataProvider()
                ->resolveReverseProperty($sourceEntityInstance, $navPropName);
            if (null === $otherPropName) {
                $srcClass = get_class($sourceEntityInstance);
                $msg = 'Bad navigation property, ' . $navPropName . ', on source model ' . $srcClass;
                throw new \InvalidArgumentException($msg);
            }
            $this->unhookSingleModel(
                $targetResourceSet,
                $targetEntityInstance,
                $sourceResourceSet,
                $sourceEntityInstance,
                $otherPropName
            );
        }
        if ($changed) {
            LaravelQuery::queueModel($sourceEntityInstance);
            LaravelQuery::queueModel($targetEntityInstance);
        }
        return true;
    }
public function unhookSingleModel(
        ResourceSet $sourceResourceSet,
        $sourceEntityInstance,
        ResourceSet $targetResourceSet,
        $targetEntityInstance,
        $navPropName
    ) {
        $relation = $this->isModelHookInputsOk($sourceEntityInstance, $targetEntityInstance, $navPropName);

        // in case the fake 'PrimaryKey' attribute got set inbound for a polymorphic-affected model, flatten it now
        unset($targetEntityInstance->PrimaryKey);

        $changed = false;

        if ($relation instanceof BelongsTo) {
            $relation->dissociate();
            $changed = true;
        } elseif ($relation instanceof BelongsToMany) {
            $relation->detach($targetEntityInstance);
            $changed = true;
        } elseif ($relation instanceof HasOneOrMany) {
            // dig up inverse property name, so we can pass it to unhookSingleModel with source and target elements
            // swapped
            $otherPropName = $this->getMetadataProvider()
                ->resolveReverseProperty($sourceEntityInstance, $navPropName);
            if (null === $otherPropName) {
                $srcClass = get_class($sourceEntityInstance);
                $msg = 'Bad navigation property, ' . $navPropName . ', on source model ' . $srcClass;
                throw new \InvalidArgumentException($msg);
            }
            $this->unhookSingleModel(
                $targetResourceSet,
                $targetEntityInstance,
                $sourceResourceSet,
                $sourceEntityInstance,
                $otherPropName
            );
        }
        if ($changed) {
            LaravelQuery::queueModel($sourceEntityInstance);
            LaravelQuery::queueModel($targetEntityInstance);
        }
        return true;
    }
public function unhookSingleModel ( ResourceSet $ sourceResourceSet , $ sourceEntityInstance , ResourceSet $ targetResourceSet , $ targetEntityInstance , $ navPropName ) { $ relation = $ this -> isModelHookInputsOk ( $ sourceEntityInstance , $ targetEntityInstance , $ navPropName ) ; // in case the fake 'PrimaryKey' attribute got set inbound for a polymorphic-affected model, flatten it now unset ( $ targetEntityInstance -> PrimaryKey ) ; $ changed = false ; if ( $ relation instanceof BelongsTo ) { $ relation -> dissociate ( ) ; $ changed = true ; } elseif ( $ relation instanceof BelongsToMany ) { $ relation -> detach ( $ targetEntityInstance ) ; $ changed = true ; } elseif ( $ relation instanceof HasOneOrMany ) { // dig up inverse property name, so we can pass it to unhookSingleModel with source and target elements // swapped $ otherPropName = $ this -> getMetadataProvider ( ) -> resolveReverseProperty ( $ sourceEntityInstance , $ navPropName ) ; if ( null === $ otherPropName ) { $ srcClass = get_class ( $ sourceEntityInstance ) ; $ msg = 'Bad navigation property, ' . $ navPropName . ', on source model ' . $ srcClass ; throw new \ InvalidArgumentException ( $ msg ) ; } $ this -> unhookSingleModel ( $ targetResourceSet , $ targetEntityInstance , $ sourceResourceSet , $ sourceEntityInstance , $ otherPropName ) ; } if ( $ changed ) { LaravelQuery :: queueModel ( $ sourceEntityInstance ) ; LaravelQuery :: queueModel ( $ targetEntityInstance ) ; } return true ; }
Removes child model from parent model.

@param ResourceSet $sourceResourceSet
@param object      $sourceEntityInstance
@param ResourceSet $targetResourceSet
@param object      $targetEntityInstance
@param $navPropName

@return bool
Removes child model from parent model .