Closed Zer0NimO-web closed 3 months ago
Hello,
for your first question, I think you should do this way:
DirectoryFactory::createMany(
3,
[
'users' => UserFactory::new([ 'sharingZones' => [ $theOneIWant ] ])->random(3),
]
);
For the second question, it is currently not possible to parametrize stories. This would be a nice addition, but which would come with some complexity because stories are only loaded once, even if you call it twice
Thank you very much. For the first question i'm afraid it won't work since i don't want to create new users, i want to get users already persisted which are linked with a specific sharingZone.
It's clear for the second case. Thanks a lot.
oups, you're right :sweat_smile:
what about randomSet()
?
It could do the job but still i don't know how to write the condition. I don't even know if it is possible to do something like :
UserFactory::randomSet(4, ['SharingZones' => /* ... is linked to $specificSharingZone ... */]);
sorry, I was not very helpful on this one :sweat_smile:
I was thinking at first you had a ManyToOne
between User
and SharingZones
. I think you cannot do it for *ToMany
:man_shrugging:
No problem, you helped me a lot!
Hello,
I couldn't find a way to do some specific things while reading Foundry documentation.
First, i want to know if it is possible for a many-to-many relationship (between DIrectory and User) to do this :
Then, i want to build stories with parameters such as :
But i don't know how to create a story which involves such parameters for the build() function.
Thanks a lot for your time.