Try
$def->save()
instead of
abc->def()->save($def);
The first line you were recalling the method for the relationship, this changes the Model back into a QueryBuilder instance so you can requery the database.
$def = $abc->def;
$def->frequency = $fields['duration'];
$abc->def()->save($def);
I use $def->save(); instead of $abc->def()->save($def);
at that time i am getting this error.
Argument 1 passed to Illuminate\Database\Eloquent\Relations\HasOneOrMany::save() must be an instance of Illuminate\Database\Eloquent\Model, none given
Thanks HARSH SHAH
Maybe you have to create the def model before saving it
$def = New Def;
$def->frequency = $fields['duration'];
$abc->def()->save($def);
note that you need to know the $abc. But I see that you are creating it in
$abc=Abc::create($fields);
so it should be ok
Thank you so much TorchSK!!!!!! Keep It Up.......
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community