samedi 15 octobre 2016

Restriction for a model to have either one type of related model or another

Suppose we have a model User that has hasOne(..) relationship defined with models A and B.

Is there any way to impose a restriction on a User model to have either model A or B (but not both) associated with it at the same time?

Example:

// valid
$user->a // Initialized
$user->b // null

// valid
$user->a // null
$user->b // Initialized

// INVALID
$user->a // Initialized
$user->b // Initialized



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire