Im trying to follow a larval tutorial and make a controller. This is what I have so far and it works for the guy in the video but mine says controller not found. I don't know what to do to fix it. Thank you!
web.php file:
Route::get('/', [PagesController::class, 'home']);
PagesController.php file:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\PagesController;
class PagesController extends Controller
{
public function home()
{
return view('welcome', [
'foo' => 'bar'
]);
}
}
CodePudding user response:
why did you use this in PagesController.php :
use App\Http\Controllers\PagesController;
This is wrong. you must remove this line of code in PagesController.php
CodePudding user response:
Do you have use App\Http\Controllers\PagesController
in web.php file?
If it doesn't exist, you should type it top of the file.