0👍
Seems like your purchase
table belongsTo
the remittance
table, so you’ll want to create the remittance model first and save the purchase model after, you can do this with a tap:
tap(Remittance::create($request->only(['sample_no', 'sample_date'])), function (Remittance $remittance) use ($purchase) {
$remittance->purchase()->save($purchase);
});
Here tap
is giving us access to the created Remittance
model in the callback, where we’re then saving the one-to-one relationship.
Source:stackexchange.com