laravel 5.8中不存在Class App \ Http \ Controllers \ Auth \ registerController类

问题描述 投票:0回答:2

我不明白这里发生了什么。在我的本地服务器上可以正常工作,但是当我将所有内容放到活动服务器上时出现此错误

enter image description here

我的网络路线

Auth::routes(['verify' => true]); 

Route::get('/', function(){ 
    return view('auth.login'); 
})->name('auth.login')->middleware('auth'); 

Route::resource('/register', 'Auth\registerController@index')->name('register');

Route::group( ['middleware' => 'auth' ], function()
{   
    Route::get('/home', 'HomeController@index')->name('home');   
    Route::group(['namespace' => 'dashboard', 'prefix' => 'dashboard'], function() {
        Route::get('/', 'DashboardController@index');
    });

    SO ON...
}

我的RegisterController

class RegisterController extends Controller
{  
    use RegistersUsers;

    protected $redirectTo = '/home';

    public function __construct()
    {
        $this->middleware('guest');       
    }

    public function index(Request $request)
    {
        $referral = '';
        $keyword = $request->get('search');
        $referral = Referral::where([
                         ['code', $keyword],
                         ['status', 0]
                         ])->first();        

        if (is_null($keyword))
            return view ( 'Auth.register');
        elseif ($referral)
            return view ( 'Auth.register', compact('referral', $referral))
                                    ->withDetails ( $referral )
                                    ->withQuery ( $keyword );
        else 
            return view ( 'Auth.register')->withMessage ( 'The code you provided is not existing or already been taken.' );
    } 

    protected function create(array $data)
    {
        $user = User::create([
            'name' => $data['name'],
            'country_code' => $data['country_code'],
            'phone_number' => $data['phone_number'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }
}

registerController路径

enter image description here

这是什么原因造成的?

谢谢您!

laravel
2个回答
1
投票

您的web.php文件中的这一行代码引起了问题

Route::resource('/register', 'Auth\registerController@index')->name('register');

您的班级名称以R开头,但您已使用r编写。此外,路由似乎是简单的获取路由,但您已将其写为资源。也改变这个。所以路线应该像

Route::get('register', 'Auth\RegisterController@index')->name('register');

0
投票

尝试一下

Route::get('register', 'Auth\RegisterController@index')->name('register');
热门问题
推荐问题
最新问题