Answer the question
In order to leave comments, you need to log in
Why is the field not editable if it is empty?
There are 2 tables, products and descriptions. Connected in a one-to-one relationship. I'm trying to edit the product description from descriptions
$product->description->body = $request->getParam('body');
$product->description->save();
$product->description->body
there is already a description in it. If absent, it returns Creating default object from empty value in ...
And $request->getParam('body');
not empty. Where did I go wrong? I would be grateful for help.
Answer the question
In order to leave comments, you need to log in
$product->description()->save(new Description(['body' => $request->body]));
или
$product->description()->update(['body' => $request->body]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question