laravel 5 : Class 'input' not found

Gammer picture Gammer · Jul 29, 2015 · Viewed 188k times · Source

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

Answer

pinkal vansia picture pinkal vansia · Jul 29, 2015

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;