-
-
Notifications
You must be signed in to change notification settings - Fork 144
Closed
Labels
Description
Currently, it's prohibited to attach HasMany and HasOne relations directly via insert or update queries:
query(Book::class)
->insert(
title: 'Timeline Taxi',
// HasMany isn't allowed
chapters: [
Chapter::new(title: 'Chapter 01'),
],
// HasOne isn't allowed
isbn: new Isbn('…'),
)
->build();Ideally we make it so that HasMany and HasOne relations get inserted/updated as well. The difficulty is that in their cases, they'll have to be inserted/updated after the original insert or update of the parent model. For that to work, we'd need a mechanism to run queries after another query (the parent query) has run.
In #1225, we added proper exceptions that prevent this from happening, but after 1.0 we could make it so that this works. However, in order to fix it properly, we need #1086