Skip to content

Indirect modification of overloaded property $text has no effect #126

Answered by MacTavish-69
MacTavish-69 asked this question in Q&A
Discussion options

You must be logged in to vote

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

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
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
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #125 on April 20, 2021 16:41.