Я пытался выяснить, возможно ли в настоящее время сделать следующее.
В основном у меня есть три модели: Customer
, Invoice
и Unit
. (Customer
имеет один Invoice
; Invoice
имеет много Unit
с).
Мне было интересно, еслиможно было легко сделать следующее:
...
# Let's pretend that further up the code that
# Customer has all the properties set and now
# being saved in the database.
$Customer->save();
# This is currently trying set the values of
# 'units' to a non-existent table column in
# 'invoices' table.
$Customer->invoice()->create([
"units" => [
[
"name" => "Unit 1",
"amount" => 999.99,
"tax" => "20%",
"type" => "+"
]
]
]);