0

I receive this error message after presing the selected value and next.

UnexpectedValueException in Response.php line 450: The Response content must be a string or object implementing __toString(), "object" given.

views/welcome.blade.php

<div class="content">

        <div class="content">

        <div class="title m-b-md">
            MENU CSS
        </div>

        Pick a new color for menu css:<br><br>
        <!-- <form action="{{route('menu.color')}}" method="post"> -->
        <form action="route/to/thing" method="post">


        <!-- <form method="POST" action="/posts"> -->
            {{ csrf_field() }}  
            <select name="cars">
                <option value="red">Red</option>
                <option value="blue">Blue</option>
                <option value="green">Green</option>
                <option value="orange">Orange</option>
            </select>
        <br><br>
        <input type="submit" value="Submit">
        </form>                  
        </div>

    </div>    


</body>

Davy YG
  • 21
  • 1
  • 4

1 Answers1

0

This should be due to what you return in the controller method which handles the route('menu.color') . __toString() method is called to convert the returned object. Your object must have properties that cannot be encoded by jason_encode which is called, when __toString() calls toJson(). Try using $hidden

class SomeClass extends Model
{
    protected $hidden = [attribute that cause error];

    // rest of class
}

in the relavent model of the object that you are returning in response to your route('menu.color') request.

refer this question .

Community
  • 1
  • 1
Achala Dissanayake
  • 810
  • 3
  • 16
  • 33