Indirect modification of overloaded property $text has no effect #126
Answered
by
MacTavish-69
MacTavish-69
asked this question in
Q&A
-
I am trying to edit a translation in my database table but I am getting this error I checked the issues and in Issue 69, it is said that it is editable just like any other eloquent model.
|
Beta Was this translation helpful? Give feedback.
Answered by
MacTavish-69
Apr 21, 2021
Replies: 2 comments
-
Anyone who would like to help out in this? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here is the solution $section_content = LanguageLine::where('key', $request->key)->get();
foreach ($section_content as $content) {
/*
* Make a copy of text property for modification since its a magic attribute
* OR it will throw error "Indirect modification of overloaded property $text has no effect"
*/
$modified_content_text = $content->text; //copy to $modified_content_text
// Modify the values in copy variable
$modified_content_text['en'] = $request->en_text;
$modified_content_text['ar'] = $request->ar_text;
// Assign the modified variable to $content->text
// If you have modified both "en, ar" then both will be updated by following line.
$content->text = $modified_content_text;
$content->save();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MacTavish-69
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the solution