Laravel Response内容必须是实现__toString()错误的字符串或对象

时间:2019-04-25 21:08:35

标签: laravel

我在为网站发布更新表单时收到以下错误:“ UnexpectedValueException:响应内容必须是实现__toString()的字符串或对象,给定为“ boolean”。在我的生产站点上。

更令人困惑的是,我在我的开发环境中有一个完全相同的代码和一个完全相同的数据库的副本,当我用相同的数据保存相同的表单时,它运行得很好,没有错误。我在dev和prod上都运行过composer update,但是该错误在prod上仍然存在,而在dev上没有错误。

为了进一步增加混乱,我对产品站点的最后一次更新是一个多月前的事,该错误仅在昨天才开始显示。它仅在用于更新计划的一种特定形式上发生,而其他形式则不受影响。

这是一个堆栈跟踪:

    [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->setContent(false)
#1 vendor/symfony/http-foundation/Response.php(206): Illuminate\Http\Response->setContent(false)
#2 vendor/laravel/framework/src/Illuminate/Routing/Router.php(615): Symfony\Component\HttpFoundation\Response->__construct(false)
#3 vendor/laravel/framework/src/Illuminate/Routing/Router.php(572): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), false)
#4 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#5 vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#6 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#7 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#8 vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(43): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#9 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Auth\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
#10 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#11 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#12 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#13 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#14 vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#15 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#17 vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#18 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#22 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#24 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#25 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#27 vendor/laravel/framework/src/Illuminate/Routing/Router.php(574): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#28 vendor/laravel/framework/src/Illuminate/Routing/Router.php(533): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#29 vendor/laravel/framework/src/Illuminate/Routing/Router.php(511): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#30 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#31 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#32 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#33 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#36 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#37 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#38 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#39 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#42 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#43 vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#44 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#45 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#46 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#47 public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#48 {main}  

更新:这是表单发布到的控制器功能。一年多来一直没有变化。

public function Positions(Request $request, $positions)
    {
        $position = Position::find($positions);
        $schedule = $position->getSchedule;
        $trainingid = $position->trainings_id;
        $dt = Carbon::parse($schedule->shoot_date_time);
        $scheduleDate = $dt->toDateString();
        $scheduleTime = $dt->toTimeString();
        $training = null;
        $contractors = array();
        if ($request->isTraining == 1) {
            $training = Training::find($trainingid);
            $contractors[$request->Photographer_trainer] = null;
            $contractors[$request->Photographer_trainee] = null;
            $contractors[$training->photographer_trainer_id] = null;
            $contractors[$training->photographer_trainee_id] = null;
            $contractors[$request->PhotoEditor_trainer] = null;
            $contractors[$request->PhotoEditor_trainee] = null;
            $contractors[$training->photo_editor_trainer_id] = null;
            $contractors[$training->photo_editor_trainee_id] = null;
            $contractors[$request->Videographer_trainer] = null;
            $contractors[$request->Videographer_trainee] = null;
            $contractors[$training->videographer_trainer_id] = null;
            $contractors[$training->videographer_trainee_id] = null;
            $contractors[$request->VideoEditor_trainer] = null;
            $contractors[$request->VideoEditor_trainee] = null;
            $contractors[$training->video_editor_trainer_id] = null;
            $contractors[$training->video_editor_trainee_id] = null;
            $contractors[$request->Drone_trainer] = null;
            $contractors[$request->Drone_trainee] = null;
            $contractors[$training->drone_trainer_id] = null;
            $contractors[$training->drone_trainee_id] = null;
            $contractors[$request->Zillow_trainer] = null;
            $contractors[$request->Zillow_trainee] = null;
            $contractors[$training->zillow_trainer_id] = null;
            $contractors[$training->zillow_trainee_id] = null;
        }
        $contractors[$request->Photographer] = null;
        $contractors[$position->photographer_id] = null;
        $contractors[$request->PhotoEditor] = null;
        $contractors[$position->photoEditor_id] = null;
        $contractors[$request->Videographer] = null;
        $contractors[$position->videographer_id] = null;
        $contractors[$request->VideoEditor] = null;
        $contractors[$position->videoEditor_id] = null;
        $contractors[$request->Drone] = null;
        $contractors[$position->drone_id] = null;
        $contractors[$request->Zillow] = null;
        $contractors[$position->zillow_id] = null;
        $contractors[$request->Webpage] = null;
        $contractors[$position->webpage_id] = null;
        $contractors[$request->Flyer] = null;
        $contractors[$position->flyer_id] = null;
        //Sets Position Check Array to check if New Position is Different from Old Position
        $positionsCheckArray = array(
            $request->Photographer => $position->photographer_id,
            $request->Videographer => $position->videographer_id,
            $request->Drone => $position->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->Photographer_trainer => $training->photographer_trainer_id,
                $request->Photographer_trainee => $training->photographer_trainee_id,
                $request->Videographer_trainer => $training->videographer_trainer_id,
                $request->Videographer_trainee => $training->videographer_trainee_id,
                $request->Drone_trainer => $training->drone_trainer_id,
                $request->Drone_trainee => $training->drone_trainee_id
            );
            $trainingsCheck = $this->checkSetAndNotEqual($trainingsCheckArray);
        }
        $positionsCheck = $this->checkSetAndNotEqual($positionsCheckArray);
        $isGoingCheck = array(
            $request->Photographer,
            $request->Videographer,
            $request->Drone,
            $request->Photographer_trainer,
            $request->Photographer_trainee,
            $request->Videographer_trainer,
            $request->Videographer_trainee,
            $request->Drone_trainer,
            $request->Drone_trainee
        );
        foreach ($contractors as $contractor => $value) {
            $notAvailable = null;
            $user = null;
            //Check to make sure contractor field is actual contractor
            if (isset($contractor) && $contractor != '' && $contractor != -1 && $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->phone)
                    && StaticMethods::checkEqualsToUser($isGoingCheck, $user->id)
                    && isset($notAvailable->noticeSent)
                    && !$notAvailable->noticeSent) {
                    $confirmationSent = (new CheckAvailabilityController)->confirmWithContractor(
                        $schedule,
                        $user,
                        $notAvailable
                    );
                    if (!$confirmationSent) {
                        return $return['isSet'] = false;
                    }
                }
            }
        }
        if ($request->isTraining == 1) {
            if (isset($position->trainings_id)) {
                Training::find($position->trainings_id)->update([
                    'photographer_trainer_id' => $request->Photographer_trainer,
                    'photographer_trainee_id' => $request->Photographer_trainee,
                    'photo_editor_trainer_id' => $request->PhotoEditor_trainer,
                    'photo_editor_trainee_id' => $request->PhotoEditor_trainee,
                    'videographer_trainer_id' => $request->Videographer_trainer,
                    'videographer_trainee_id' => $request->Videographer_trainee,
                    'video_editor_trainer_id' => $request->VideoEditor_trainer,
                    'video_editor_trainee_id' => $request->VideoEditor_trainee,
                    'drone_trainer_id' => $request->Drone_trainer,
                    'drone_trainee_id' => $request->Drone_trainee,
                    'zillow_trainer_id' => $request->Zillow_trainer,
                    'zillow_trainee_id' => $request->Zillow_trainee,
                    'shootDate' => $position->shootDate
                ]);
            } else {
                $trainingCreate = Training::create([
                    'photographer_trainer_id' => $request->Photographer_trainer,
                    'photographer_trainee_id' => $request->Photographer_trainee,
                    'photo_editor_trainer_id' => $request->PhotoEditor_trainer,
                    'photo_editor_trainee_id' => $request->PhotoEditor_trainee,
                    'videographer_trainer_id' => $request->Videographer_trainer,
                    'videographer_trainee_id' => $request->Videographer_trainee,
                    'video_editor_trainer_id' => $request->VideoEditor_trainer,
                    'video_editor_trainee_id' => $request->VideoEditor_trainee,
                    'drone_trainer_id' => $request->Drone_trainer,
                    'drone_trainee_id' => $request->Drone_trainee,
                    'zillow_trainer_id' => $request->Zillow_trainer,
                    'zillow_trainee_id' => $request->Zillow_trainee,
                    'shootDate' => $position->shootDate
                ]);
                $trainingid = $trainingCreate->id;
            }
        }
        $task = $position->update([
            'photographer_id' => $request->Photographer,
            'photoEditor_id' => $request->PhotoEditor,
            'videographer_id' => $request->Videographer,
            'videoEditor_id' => $request->VideoEditor,
            'drone_id' => $request->Drone,
            'webpage_id' => $request->Webpage,
            'flyer_id' => $request->Flyer,
            'zillow_id' => $request->Zillow,
            'trainings_id' => $trainingid
        ]);
        $return['isSet'] = $task;
        return $return;
    }

0 个答案:

没有答案