类 AppHttpControllersUserController 不存在

Class AppHttpControllersUserController Does Not Exist(类 AppHttpControllersUserController 不存在)
本文介绍了类 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 不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

In PHP how can you clear a WSDL cache?(在 PHP 中如何清除 WSDL 缓存?)
failed to open stream: HTTP wrapper does not support writeable connections(无法打开流:HTTP 包装器不支持可写连接)
Stop caching for PHP 5.5.3 in MAMP(在 MAMP 中停止缓存 PHP 5.5.3)
Caching HTTP responses when they are dynamically created by PHP(缓存由 PHP 动态创建的 HTTP 响应)
Memcached vs APC which one should I choose?(Memcached 与 APC 我应该选择哪一个?)
What is causing quot;Unable to allocate memory for poolquot; in PHP?(是什么导致“无法为池分配内存?在 PHP 中?)