Class AppHttpControllersUserController Does Not Exist(类 AppHttpControllersUserController 不存在)
问题描述
加载路由/users 或/user/add 时出现问题并返回错误;
Having the issue when loading the route /users or /user/add and being return an error of;
Route.php 第 280 行中的 ReflectionException:类AppHttpControllersAppControllersUserController 不存在
ReflectionException in Route.php line 280: Class AppHttpControllersAppControllersUserController does not exist
UserController 确实存在,但它不在我的控制器文件夹中的文件夹中.
The UserController does exist and it is not in a folder within my controllers folder.
我的路由文件;
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 AppHttpControllers;
use AppHttpRequests;
use AppUser;
use AppUserTypes;
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();部分错误消失,是否与此有关?
推荐答案
Laravel 8.x 更新有不同的路由使用方式.
Laravel 8.x update has a different way of using routes.
以前是:
Route::get('/', 'PagesController@index');
现在变成了
Route::get('/',[PagesController::class, 'index']);
注意:不要忘记在顶部的 routes(web.php) 文件中导入(使用)您的控制器.喜欢:
use AppHttpControllersPagesController;
这篇关于类 AppHttpControllersUserController 不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:类 AppHttpControllersUserController 不存在
基础教程推荐
- 使用 PDO 转义列名 2021-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01