Support the ongoing development of Laravel.io →
posted 5 years ago
Last updated 1 year ago.
0
moderator

You should move the not found logic to the controller and there you can set the statuscode for the view.

public function show(DealerSubsite $dealer, $entity_slug, $entity_id) {
    $statusCode = 200;
    // do something to decide if it is found or not
    if (!$found) {
        $statusCode = 404;
    }
    return response()->view('pages.subsites.inventories.show', compact('dealer', 'entity_id'), $statusCode);
}

See: https://laravel.com/docs/5.6/responses#view-responses

Last updated 5 years ago.
0

Perfect. Thank you for the detailed response, as well as for the link.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Eric Brown eb112 Joined 27 Aug 2018

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.