hasandev123's avatar

Route to View directly

Hello

Is there any way to bypass controller, and return to view directly from route?

1 like
4 replies
bobbybouwmann's avatar

Yeah you can do something like this if you also need to handle some other actions

Route('my-url', function () {
    $posts = Post::all();

    return view('my.view', compact('posts'));
});
3 likes
tisuchi's avatar

@alexdavid

There is a correction, if you need to use this before laravel 5.5, I think @bobbybouwmann solutions is the best.

My part only works for Laravel 5.5 version. Keep in mind.

6 likes

Please or to participate in this conversation.