Illuminate\Database\Eloquent\Relations\BelongsTo::dissociate PHP Method

dissociate() public method

Dissociate previously associated model from the given parent.
public dissociate ( ) : Model
return Illuminate\Database\Eloquent\Model
    public function dissociate()
    {
        $this->parent->setAttribute($this->foreignKey, null);
        return $this->parent->setRelation($this->relation, null);
    }

Usage Example

コード例 #1
2
ファイル: Helper.php プロジェクト: exolnet/laravel-module
 public static function setBelongsTo(BelongsTo $belongsTo, $object = null)
 {
     return $object ? $belongsTo->associate($object) : $belongsTo->dissociate();
 }