类应用程序\http\控制器\用户控制器不存在
2022-08-30 21:35:37
在加载路由 /users 或 /user/add 时出现问题,并返回错误;
Route.php第 280 行中的反射异常:类 App\Http\Controllers\App\Controllers\UserController 不存在
用户控制器确实存在,并且它不在我的控制器文件夹中。
我的路线文件;
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');
});
});
我的用户控制器;
<?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');
}
}
当我删除 User::create();部分错误消失了,它会与此有关吗?