This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

piers
piers

So I noticed that when you attach a file in the backend the attachment knows the backend field from the CMS and sets constraints so that you can have multiple files attached to a model.

Would it be possible for basic MorphOne relations to use a similar constraint system to allow for easy multiple instances of a related model?

Like this, https://github.com/octobercms/library/blob/5e5aae96e9d6c8cc7a80c0b5a97de7a33b44c167/src/Database/Relations/AttachOneOrMany.php#L36

Last updated

piers
piers

Hmm, I can add the attributes to the MorphOneOrMany trait, but that would break existing MorphOne usage as the field comes directly from and adding an option in the constructor feels messy and would mean messing around with the Model class...

Maybe being able to use the AttachOne relation would be more realistic, who says that an attachment has to be a file!?

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.