本文介紹了類 AppHttpControllersUserController 不存在的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
加載路由/users 或/user/add 時出現(xiàn)問題并返回錯誤;
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');
現(xiàn)在變成了
Route::get('/',[PagesController::class, 'index']);
注意:不要忘記在頂部的 routes(web.php) 文件中導入(使用)您的控制器.喜歡:
use AppHttpControllersPagesController;
這篇關于類 AppHttpControllersUserController 不存在的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!