0

I created a controller using artisan in my Laravel application, here's the code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class NavigationController extends Controller {

    public function welcome() {
        return view("welcome");
    }

}

When I use a Closure or load the view directly, everything works fine. But, when I load view from inside a controller, it couldn't find it. Here's my web.php file's code:

Route::get('/', function () {
    return view('NavigationController@welcome');
});

The error it shows:

InvalidArgumentException View [NavigationController@welcome] not found:

image

1 Answer 1

1

It's because the view NavigationController@welcome doesn't exist, this is a method.

Either you load the view from the closure :

Route::get('/', function() {
    return view('welcome');
});

Either you call a method of the controller and this method loads the view:

Route::get('/', 'NavigationController@welcome');

Please see: Laravel Routing documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.