chipit24
chipit24

Reputation: 6987

Laravel dissociate for hasOne relation

For a belongsTo relationship, I can use dissociate, but what is the equivalent for hasOne?

Ex. Phone belongs to User:

$phone->user()->dissociate(); // success
$user->phone()->dissociate(); // fail

Upvotes: 4

Views: 1686

Answers (1)

Gacek
Gacek

Reputation: 10312

It seems there is no reverse equivallent.

Since

$user->phone()

returns an Illuminate\Database\Eloquent\Relations\HasOne object, lets take a look on that file - there is no dissociate() equivallent method. But HasOne extends HasOneOrMany, so just to be shure let's take a look on that too. Still nothing.

Upvotes: 3

Related Questions