laravel 5 : 未找到类“输入”

在我的文件中,我有:routes.php

Route::get('/', function () {

    return view('login');
});

Route::get('/index', function(){
    return view('index');
});

Route::get('/register', function(){
    return view('register');
});
Route::post('/register',function(){

    $user = new \App\User;
    $user->username = input::get('username');
    $user->email  = input::get('email');
    $user->password = Hash::make(input::get('username'));
    $user->designation = input::get('designation');
    $user->save();

});

我有一个用户注册表格。我还在 .routes.php

但是当我注册用户时出现错误。错误:

FatalErrorException in routes.php line 61:
Class 'input' not found

答案 1

它是,但不是.此提交删除了外观定义,因此您必须手动将其添加到数组中,如下所示,InputinputInputconfig/app.phpaliases

'Input' => Illuminate\Support\Facades\Input::class,

或者您可以根据需要直接导入立面,Input

use Illuminate\Support\Facades\Input;

答案 2

对于 laravel 5.2<

打开该类并将其添加到 :config/app.phpInputaliases

'aliases' => [
// ...
  'Input' => Illuminate\Support\Facades\Input::class,
// ...
],

对于 laravel 5.2>=

更改为Input::Request::


推荐