Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

append a new entity to a multiple relation via $model->emails[] = '[email protected]' #35

Open
phrakon opened this issue Aug 10, 2018 · 3 comments
Assignees

Comments

@phrakon
Copy link

phrakon commented Aug 10, 2018

I suggest to append the feature in the future. I think it would be useful.

@juban
Copy link
Contributor

juban commented Aug 10, 2018

Hi @phrakon,

I'm afraid that won't be possible because setting a relation value is done through PHP magic setters.
Setting new relations that way won't work due to PHP limitations.
However, you could workaround that doing something like:

$emails = $model->emails;
$emails[] = '[email protected]';
$emails[] = '[email protected]';
$model->emails = $emails;

Another possibility would be to create a new method that could do that. I will think about it.

Thanks.

@phrakon
Copy link
Author

phrakon commented Aug 10, 2018

It's so strange. I was doing the same behavior via ArrayObject. And it worked...

@juban
Copy link
Contributor

juban commented Aug 11, 2018

@phrakon I'm curious about ArrayObject. Could you elaborate a bit? How would you do that exactly?

@nstCactus nstCactus self-assigned this Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants