laravel 5 : Class 'input' not found

2019-01-30 02:36发布

In my routes.php file I have :

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();

});

I have a form for users registration. I am also taking the form inputs value in the routes.php.

But the error comes up when I register a user . Error:

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

11条回答
闹够了就滚
2楼-- · 2019-01-30 03:22

It is Input and not input. This commit removed Input facade definition from config/app.php hence you have to manually add that in to aliases array as below,

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

Or You can import Input facade directly as required,

use Illuminate\Support\Facades\Input;
查看更多
叛逆
3楼-- · 2019-01-30 03:27

For laravel < 5.2:

Open config/app.php and add the Input class to aliases:

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

For laravel >= 5.2

Change Input:: to Request::

查看更多
smile是对你的礼貌
4楼-- · 2019-01-30 03:27

'Input' => Illuminate\Support\Facades\Input::class, add it to App.php.

查看更多
神经病院院长
5楼-- · 2019-01-30 03:29

Miscall of Class it should be ‘Input’ not ‘input’

查看更多
Luminary・发光体
6楼-- · 2019-01-30 03:32

Declaration in config/app.php under aliases:-

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

Or You can import Input facade directly as required,

use Illuminate\Support\Facades\Input;

or

use Illuminate\Support\Facades\Input as input;
查看更多
登录 后发表回答