laravel 5 : Class 'input' not found

前端 未结 14 901
滥情空心
滥情空心 2020-12-02 07:35

In my routes.php file I have :

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

    return view(\'login\');
});

Route::get(\'/index\', function(){
    return v         


        
相关标签:
14条回答
  • 2020-12-02 07:48

    This clean code snippet works fine for me:

    use Illuminate\Http\Request;
    Route::post('/register',function(Request $request){
    
       $user = new \App\User;
       $user->username = $request->input('username');
       $user->email  = $request->input('email');
       $user->password = Hash::make($request->input('username'));
       $user->designation = $request->input('designation');
       $user->save();
    });
    
    0 讨论(0)
  • 2020-12-02 07:52

    In larvel => 6 Version:

    Input no longer exists In larvel 6,7,8 Version. Use Request instead of Input.

    Based on the Laravel docs, since version 6.x Input has been removed.

    The Input Facade

    Likelihood Of Impact: Medium

    The Input facade, which was primarily a duplicate of the Request facade, has been removed. If you are using the Input::get method, you should now call the Request::input method. All other calls to the Input facade may simply be updated to use the Request facade.

    use Illuminate\Support\Facades\Request;
    ..
    ..
    ..
     public function functionName(Request $request)
        {
            $searchInput = $request->q;
    }
    
    0 讨论(0)
  • 2020-12-02 07:53

    Add this in config/app.php under aliases:-

    'Input' => Illuminate\Support\Facades\Input::class,
    
    0 讨论(0)
  • 2020-12-02 07:55

    Miscall of Class it should be Input not input

    0 讨论(0)
  • 2020-12-02 07:57

    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;
    
    0 讨论(0)
  • 2020-12-02 07:59

    In Laravel 5.2 Input:: is replaced with Request::

    use

    Request::
    

    Add to the top of Controller or any other Class

    use Illuminate\Http\Request;
    
    0 讨论(0)
提交回复
热议问题