简体   繁体   中英

Blank page displayed when trying to display a view from a controller in Laravel 8

I have a route set up correctly... I know because the dd($dev) shows me the model instance when not commented out. ($dev is a model instance that is successfully grabbed after translating the slugs in the URL in other funcitons before getting to show)

When I view the page/route with dd($dev) commented out, I get a blank page. No error.

DevelopmentController.php:

    public function show($dev){
        if(is_numeric($dev)) $dev=Development::find($dev);

        if(!is_object($dev)){
            dd('ERROR: No development found ', $dev); // TODO handle error
        }

        if (View::exists('development')) {
            // dd($dev); this shows development model instance OK!
            return view('development' , ['development'=>$dev]);
        }
        dd("View doesn't exist");
    }

I have confirmed the view works with the following route which displays the view correctly;

Route::get('/test', function () {  return view('development', ['development'=>Development::find(228)]); });

/resources/views/development.blade.php:

<x-layout>
    <h1>Development: {{$development->description}}</h1>

</x-layout>

I have other controllers displaying their views successfully. I must be missing something obvious, but struggling to spot it? Any ideas?

Just for reference, I was stupid and returning the view from the show function, but not returning that value back to the route.

public function findShow($countySlug, $locationSlug, $developmentSlug){
    $dev=$this->find($countySlug, $locationSlug, $developmentSlug);
    return $this->show($dev);
}

Also didnt' help that I didn't put this in the question. Sorry!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM