【发布时间】:2017-04-21 19:02:48
【问题描述】:
对于belongsTo 关系,我可以使用dissociate,但hasOne 的等价物是什么?
例如。 Phone 属于User:
$phone->user()->dissociate(); // success
$user->phone()->dissociate(); // fail
【问题讨论】:
对于belongsTo 关系,我可以使用dissociate,但hasOne 的等价物是什么?
例如。 Phone 属于User:
$phone->user()->dissociate(); // success
$user->phone()->dissociate(); // fail
【问题讨论】:
似乎没有反向等价物。
自从
$user->phone()
返回一个Illuminate\Database\Eloquent\Relations\HasOne 对象,让我们看看that file - 没有dissociate() 等效方法。但是HasOne 扩展了HasOneOrMany,所以为了安全起见,让我们使用look on that too。依然没有。
【讨论】: