3
belongsTo
の関係の場合、dissociate
を使用できますが、hasOne
の場合はどうなりますか?LaravelはhasOneの関係を解消します
Ex。 Phone
はUser
に属している:逆equivallentがないようだ
$phone->user()->dissociate(); // success
$user->phone()->dissociate(); // fail
belongsTo
の関係の場合、dissociate
を使用できますが、hasOne
の場合はどうなりますか?LaravelはhasOneの関係を解消します
Ex。 Phone
はUser
に属している:逆equivallentがないようだ
$phone->user()->dissociate(); // success
$user->phone()->dissociate(); // fail
。
$user->phone()
以来
は、Illuminate\Database\Eloquent\Relations\HasOne
オブジェクトを返しますthat fileに見てみましょう - 何dissociate() equivallent方法はありません。しかし、HasOne
はHasOneOrMany
に広がります。ちょうどshureになるのはlook on that tooです。まだ何も。