title: Laravel The Response content must be a string or object implementing __toString() error
body: <p>I am getting the following error when I am POSTing an update form for my site: "UnexpectedValueException: The Response content must be a string or object implementing __toString(), "boolean" given." on my production site. </p>
  
  <p>What makes this more confusing is I have a copy of the same exact code and the same exact database on my dev environment and when I save the same form with the same data, it goes through just fine, no errors. I have run <code>composer update</code> on both dev and prod, yet the error still persists on prod, no error on dev.</p>
  
  <p>To add even more to the confusion, my last update to the prod site was over a month ago and the error started showing up only yesterday. It only happens on one particular form used for updating schedules, but no other form is affected.</p>
  
  <p>Here is a stacktrace:</p>
  
  <pre><code>    [2019-04-25 20:57:45] production.ERROR: UnexpectedValueException: The Response content must be a string or object implementing __toString(), "boolean" given. in /home/unlikem5/public_html/myuladmin/vendor/symfony/http-foundation/Response.php:399
  Stack trace:
  #0 vendor/laravel/framework/src/Illuminate/Http/Response.php(41): Symfony\Component\HttpFoundation\Response-&gt;setContent(false)
  #1 vendor/symfony/http-foundation/Response.php(206): Illuminate\Http\Response-&gt;setContent(false)
  #2 vendor/laravel/framework/src/Illuminate/Routing/Router.php(615): Symfony\Component\HttpFoundation\Response-&gt;__construct(false)
  #3 vendor/laravel/framework/src/Illuminate/Routing/Router.php(572): Illuminate\Routing\Router-&gt;prepareResponse(Object(Illuminate\Http\Request), false)
  #4 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #5 vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #6 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Routing\Middleware\SubstituteBindings-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #7 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #8 vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(43): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #9 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Auth\Middleware\Authenticate-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #10 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #11 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(65): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #12 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #13 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #14 vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #15 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\View\Middleware\ShareErrorsFromSession-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #16 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #17 vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #18 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Session\Middleware\StartSession-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #19 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #20 vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #21 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #22 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #23 vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #24 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #25 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #26 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #27 vendor/laravel/framework/src/Illuminate/Routing/Router.php(574): Illuminate\Pipeline\Pipeline-&gt;then(Object(Closure))
  #28 vendor/laravel/framework/src/Illuminate/Routing/Router.php(533): Illuminate\Routing\Router-&gt;runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
  #29 vendor/laravel/framework/src/Illuminate/Routing/Router.php(511): Illuminate\Routing\Router-&gt;dispatchToRoute(Object(Illuminate\Http\Request))
  #30 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router-&gt;dispatch(Object(Illuminate\Http\Request))
  #31 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel-&gt;Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
  #32 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #33 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #34 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #35 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #36 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #37 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #38 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #39 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\ValidatePostSize-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #40 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #41 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #42 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode-&gt;handle(Object(Illuminate\Http\Request), Object(Closure))
  #43 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
  #44 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
  #45 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline-&gt;then(Object(Closure))
  #46 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel-&gt;sendRequestThroughRouter(Object(Illuminate\Http\Request))
  #47 public/index.php(53): Illuminate\Foundation\Http\Kernel-&gt;handle(Object(Illuminate\Http\Request))
  #48 {main}  
  </code></pre>
  
  <p>Update: Here is the controller function that the form posts to. It has remained unchanged for over a year now.</p>
  
  <pre><code>public function Positions(Request $request, $positions)
      {
          $position = Position::find($positions);
          $schedule = $position-&gt;getSchedule;
          $trainingid = $position-&gt;trainings_id;
          $dt = Carbon::parse($schedule-&gt;shoot_date_time);
          $scheduleDate = $dt-&gt;toDateString();
          $scheduleTime = $dt-&gt;toTimeString();
          $training = null;
          $contractors = array();
          if ($request-&gt;isTraining == 1) {
              $training = Training::find($trainingid);
              $contractors[$request-&gt;Photographer_trainer] = null;
              $contractors[$request-&gt;Photographer_trainee] = null;
              $contractors[$training-&gt;photographer_trainer_id] = null;
              $contractors[$training-&gt;photographer_trainee_id] = null;
              $contractors[$request-&gt;PhotoEditor_trainer] = null;
              $contractors[$request-&gt;PhotoEditor_trainee] = null;
              $contractors[$training-&gt;photo_editor_trainer_id] = null;
              $contractors[$training-&gt;photo_editor_trainee_id] = null;
              $contractors[$request-&gt;Videographer_trainer] = null;
              $contractors[$request-&gt;Videographer_trainee] = null;
              $contractors[$training-&gt;videographer_trainer_id] = null;
              $contractors[$training-&gt;videographer_trainee_id] = null;
              $contractors[$request-&gt;VideoEditor_trainer] = null;
              $contractors[$request-&gt;VideoEditor_trainee] = null;
              $contractors[$training-&gt;video_editor_trainer_id] = null;
              $contractors[$training-&gt;video_editor_trainee_id] = null;
              $contractors[$request-&gt;Drone_trainer] = null;
              $contractors[$request-&gt;Drone_trainee] = null;
              $contractors[$training-&gt;drone_trainer_id] = null;
              $contractors[$training-&gt;drone_trainee_id] = null;
              $contractors[$request-&gt;Zillow_trainer] = null;
              $contractors[$request-&gt;Zillow_trainee] = null;
              $contractors[$training-&gt;zillow_trainer_id] = null;
              $contractors[$training-&gt;zillow_trainee_id] = null;
          }
          $contractors[$request-&gt;Photographer] = null;
          $contractors[$position-&gt;photographer_id] = null;
          $contractors[$request-&gt;PhotoEditor] = null;
          $contractors[$position-&gt;photoEditor_id] = null;
          $contractors[$request-&gt;Videographer] = null;
          $contractors[$position-&gt;videographer_id] = null;
          $contractors[$request-&gt;VideoEditor] = null;
          $contractors[$position-&gt;videoEditor_id] = null;
          $contractors[$request-&gt;Drone] = null;
          $contractors[$position-&gt;drone_id] = null;
          $contractors[$request-&gt;Zillow] = null;
          $contractors[$position-&gt;zillow_id] = null;
          $contractors[$request-&gt;Webpage] = null;
          $contractors[$position-&gt;webpage_id] = null;
          $contractors[$request-&gt;Flyer] = null;
          $contractors[$position-&gt;flyer_id] = null;
          //Sets Position Check Array to check if New Position is Different from Old Position
          $positionsCheckArray = array(
              $request-&gt;Photographer =&gt; $position-&gt;photographer_id,
              $request-&gt;Videographer =&gt; $position-&gt;videographer_id,
              $request-&gt;Drone =&gt; $position-&gt;drone_id
          );
          //If it exists, Sets Training Check Array to check if New Training is Different from Old Training
          $trainingsCheck = false;
          if (isset($training)) {
              $trainingsCheckArray = array(
                  $request-&gt;Photographer_trainer =&gt; $training-&gt;photographer_trainer_id,
                  $request-&gt;Photographer_trainee =&gt; $training-&gt;photographer_trainee_id,
                  $request-&gt;Videographer_trainer =&gt; $training-&gt;videographer_trainer_id,
                  $request-&gt;Videographer_trainee =&gt; $training-&gt;videographer_trainee_id,
                  $request-&gt;Drone_trainer =&gt; $training-&gt;drone_trainer_id,
                  $request-&gt;Drone_trainee =&gt; $training-&gt;drone_trainee_id
              );
              $trainingsCheck = $this-&gt;checkSetAndNotEqual($trainingsCheckArray);
          }
          $positionsCheck = $this-&gt;checkSetAndNotEqual($positionsCheckArray);
          $isGoingCheck = array(
              $request-&gt;Photographer,
              $request-&gt;Videographer,
              $request-&gt;Drone,
              $request-&gt;Photographer_trainer,
              $request-&gt;Photographer_trainee,
              $request-&gt;Videographer_trainer,
              $request-&gt;Videographer_trainee,
              $request-&gt;Drone_trainer,
              $request-&gt;Drone_trainee
          );
          foreach ($contractors as $contractor =&gt; $value) {
              $notAvailable = null;
              $user = null;
              //Check to make sure contractor field is actual contractor
              if (isset($contractor) &amp;&amp; $contractor != '' &amp;&amp; $contractor != -1 &amp;&amp; $contractor != 0) {
                  //Get Contractor
                  $user = User::find($contractor);
                  //Check if this contractor was already not available because of this event
                  $notAvailable = StaticMethods::checkNotAvailable(
                      $schedule,
                      $user,
                      $scheduleDate,
                      $scheduleTime,
                      $isGoingCheck
                  );
                  if (isset($user-&gt;phone)
                      &amp;&amp; StaticMethods::checkEqualsToUser($isGoingCheck, $user-&gt;id)
                      &amp;&amp; isset($notAvailable-&gt;noticeSent)
                      &amp;&amp; !$notAvailable-&gt;noticeSent) {
                      $confirmationSent = (new CheckAvailabilityController)-&gt;confirmWithContractor(
                          $schedule,
                          $user,
                          $notAvailable
                      );
                      if (!$confirmationSent) {
                          return $return['isSet'] = false;
                      }
                  }
              }
          }
          if ($request-&gt;isTraining == 1) {
              if (isset($position-&gt;trainings_id)) {
                  Training::find($position-&gt;trainings_id)-&gt;update([
                      'photographer_trainer_id' =&gt; $request-&gt;Photographer_trainer,
                      'photographer_trainee_id' =&gt; $request-&gt;Photographer_trainee,
                      'photo_editor_trainer_id' =&gt; $request-&gt;PhotoEditor_trainer,
                      'photo_editor_trainee_id' =&gt; $request-&gt;PhotoEditor_trainee,
                      'videographer_trainer_id' =&gt; $request-&gt;Videographer_trainer,
                      'videographer_trainee_id' =&gt; $request-&gt;Videographer_trainee,
                      'video_editor_trainer_id' =&gt; $request-&gt;VideoEditor_trainer,
                      'video_editor_trainee_id' =&gt; $request-&gt;VideoEditor_trainee,
                      'drone_trainer_id' =&gt; $request-&gt;Drone_trainer,
                      'drone_trainee_id' =&gt; $request-&gt;Drone_trainee,
                      'zillow_trainer_id' =&gt; $request-&gt;Zillow_trainer,
                      'zillow_trainee_id' =&gt; $request-&gt;Zillow_trainee,
                      'shootDate' =&gt; $position-&gt;shootDate
                  ]);
              } else {
                  $trainingCreate = Training::create([
                      'photographer_trainer_id' =&gt; $request-&gt;Photographer_trainer,
                      'photographer_trainee_id' =&gt; $request-&gt;Photographer_trainee,
                      'photo_editor_trainer_id' =&gt; $request-&gt;PhotoEditor_trainer,
                      'photo_editor_trainee_id' =&gt; $request-&gt;PhotoEditor_trainee,
                      'videographer_trainer_id' =&gt; $request-&gt;Videographer_trainer,
                      'videographer_trainee_id' =&gt; $request-&gt;Videographer_trainee,
                      'video_editor_trainer_id' =&gt; $request-&gt;VideoEditor_trainer,
                      'video_editor_trainee_id' =&gt; $request-&gt;VideoEditor_trainee,
                      'drone_trainer_id' =&gt; $request-&gt;Drone_trainer,
                      'drone_trainee_id' =&gt; $request-&gt;Drone_trainee,
                      'zillow_trainer_id' =&gt; $request-&gt;Zillow_trainer,
                      'zillow_trainee_id' =&gt; $request-&gt;Zillow_trainee,
                      'shootDate' =&gt; $position-&gt;shootDate
                  ]);
                  $trainingid = $trainingCreate-&gt;id;
              }
          }
          $task = $position-&gt;update([
              'photographer_id' =&gt; $request-&gt;Photographer,
              'photoEditor_id' =&gt; $request-&gt;PhotoEditor,
              'videographer_id' =&gt; $request-&gt;Videographer,
              'videoEditor_id' =&gt; $request-&gt;VideoEditor,
              'drone_id' =&gt; $request-&gt;Drone,
              'webpage_id' =&gt; $request-&gt;Webpage,
              'flyer_id' =&gt; $request-&gt;Flyer,
              'zillow_id' =&gt; $request-&gt;Zillow,
              'trainings_id' =&gt; $trainingid
          ]);
          $return['isSet'] = $task;
          return $return;
      }
  </code></pre>