Reputation: 503
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:
Upvotes: 0
Views: 745
Reputation: 91
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
Upvotes: 1