You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I completely understand why this is here, if you have a Morphable field, its a reasonable assumption that it must be morphable to more than one type, otherwise why be morphable in the first place?
In reality, we're adding relationships we know long-term are going to be morphable, i.e. for a model morph on an approval system, but on it's first iteration we're only supporting one type, making it morphable for future iterations, but we don't have a second type to support yet.
Can't see any issues with removing the > 1 check in the MorphTo class, I've overriden this in our codebase to remove the restriction and works fine. The other option is to pass the same type in twice.
public static function make(string $fieldName, array $relations): self
{
/* @phpstan-ignore-next-line */
return new self($fieldName, $relations);
}
/**
* MorphMany constructor.
*/
public function __construct(string $fieldName, array $relations)
{
parent::__construct($fieldName);
$this->relations = $relations;
}
Both workarounds seem to hold up, but it'd be nice if this was an option in the package itself?
Thanks!
The text was updated successfully, but these errors were encountered:
I completely understand why this is here, if you have a Morphable field, its a reasonable assumption that it must be morphable to more than one type, otherwise why be morphable in the first place?
In reality, we're adding relationships we know long-term are going to be morphable, i.e. for a
model
morph on an approval system, but on it's first iteration we're only supporting one type, making it morphable for future iterations, but we don't have a second type to support yet.Can't see any issues with removing the > 1 check in the
MorphTo
class, I've overriden this in our codebase to remove the restriction and works fine. The other option is to pass the sametype
in twice.Both workarounds seem to hold up, but it'd be nice if this was an option in the package itself?
Thanks!
The text was updated successfully, but these errors were encountered: