laravel update child
// to update child records.
// Offer Modal
public function project()
{
return $this->belongsTo(Project::class, 'project_id');
}
// we are using -> since 1 project is belongs to many offer
$offer->project->update(
[
'projectstatus_id' => 6,
]
);
// Offer Modal
public function offerTransactions()
{
return $this->hasMany(Transaction::class, 'offer_id', 'id');
}
// we are using -> and () since 1 offer can have many transactions
$offer->offerTransactions()->update([
'transaction_status' => 'Approved',
]);
//Please, mention if there is better way/idea.