antonioribeiro / health

Laravel Health Panel
BSD 3-Clause "New" or "Revised" License
1.95k stars 197 forks source link

Can't use domain.com/health/panel, Undefined variable: health #133

Open poor-bob opened 5 years ago

poor-bob commented 5 years ago

PHP version: 7.2.11 Laravel version: 5.7.*

I receive the following error when attempting to access /health/panel:

Method Illuminate\View\View::__toString() must not throw an exception, caught ErrorException: Undefined variable: health (View: /mnt/c/Users/{removed}/Desktop/dev/laravel/resources/views/vendor/pragmarx/health/default/panel.blade.php)

This is the controller code that's failing

    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @throws \Exception
     */
    public function panel()
    {
        $this->healthService->setAction('panel');

        return response((string) view(config('health.views.panel'))->with('laravel', ['health' => config('health')]));
    }

This is the view code that fails in panel.blade.php

                    @foreach($health as $item)
                        @include(
                            config('health.views.partials.well'),
                            [
                                'itemName' => $item['name'],
                                'itemHealth' => $item['health']['healthy'],
                                'itemMessage' => $item['health']['message'],
                                'columnSize' => $item['columnSize'] ?: $item['column_size']
                            ]
                        )
                    @endforeach

When I dd(config('health')); it returns the expected json object, but for some reason $health is undefined.