WallyJ
6 months ago
2265
8
Laravel

ReflectionException Class App\Http\Controllers\User does not exist

Posted 6 months ago by WallyJ

I added the "User" controller through

php artisan make:controller User

and hit enter before I realized I didn't add the word "Controller" to the end.

I changed it in the file name to "UserController.php", and in web.php, but I still receive the error:

ReflectionException Class App\Http\Controllers\User does not exist

I'm not sure where else to look. I don't see where I have referenced the Controller with just "User".

I receive the error when I visit

My code in web.php is: Route::get('users/{user}', '[email protected]');

My UserController is:

<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;

class UserController extends Controller
{
    public function edit(User $user)
    {
        $user = Auth::user();
         return view('user.edit', compact('user'));
    }

    public function update(User $user)
    { 

        $user->name = request('name');
        $user->email = request('email');
        $user->save();

        return view('home', ['user' => $user]);
    }
}

Thanks.

Please sign in or create an account to participate in this conversation.