Having the issue when loading the route /users or /user/add and being return an error of;
ReflectionException in Route.php line 280: Class App\Http\Controllers\App\Controllers\UserController does not exist
The UserController does exist and it is not in a folder within my controllers folder.
My route file;
Route::group(['middleware' => 'auth'], function(){ Route::get('/route/selector', 'PagesController@selectRoute'); // Admin Only // Route::group(['middleware' => 'isAdmin'], function(){ Route::get('/admin', 'AdminController@index'); Route::get('/users', 'UserController@index'); Route::get('/user/add', 'UserController@getAdd'); Route::post('/user/add', 'UserController@postAdd'); Route::get('/user/edit/{id}', 'UserController@getEdit'); Route::post('/user/edit/{id}', 'UserController@postEdit'); Route::get('/user/delete/{id}', 'UserController@delete'); }); }); My UserController;
<?php namespace App\Http\Controllers; use App\Http\Requests; use App\User; use App\UserTypes; use Auth; use Hashids; use Redirect; use Request; use Hash; class UserController extends Controller { public function index(){ $users = User::get(); return view('users.index', compact('users')); } public function getAdd(){ $user_type = UserTypes::pluck('user_type', 'id'); return view('users.add', compact('user_type')); } public function postAdd(){ $input = Request::all(); $password = str_random(8); User::create( 'email' => $input['email'], 'password' => Hash::make($password), 'first_name' => $input['first_name'], 'surname' => $input['surname'], 'phone_number' => $input['phone_number'], 'user_type' => $input['user_type'], ); return Redirect::action('UserController@index'); } public function getEdit($id){ } public function postEdit($id){ } public function delete($id){ User::find(current(Hashids::decode($id)))->delete(); return Redirect::action('UserController@index'); } } When I remove the User::create(); part the error disappears, will it have something to do with this?
composer dumpautocommand.UserController? As you are usingnamespace App\Http\Controllersit has to be insideapp/Http/Controllersdirectory