Home > Software design >  CATCHING URL FROM ROUTE // php laravel
CATCHING URL FROM ROUTE // php laravel

Time:09-15

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Input;

Although I use these libraries, the input gives an error. Even if I add request or name input path to app.php in the config file, the problem is not resolved.

public function get_deneme(){
    $name=Input::get('name');
    $var="asd";
    return view('deneme')->with('var',$var);
}

ERROR: Input is underlined (Undefined type 'Illuminate\Support\Facades\Input'.)

NOTE : Laravel Framework 9.29.0

CodePudding user response:

As aynber mentioned in the comments Input was a very very old feature, since Laravel 5.2 you can use the following to get inputs

request()->get('name');

But since this still is not the best way to use the request, you can do it like this

use Illuminate\Http\Request

public function get_deneme(Request $request){
   $name = $request->name;
   $var = "asd";

   return view('deneme')->with('var',$var);
}
  • Related