Ad

Class '...\Input' Not Found

- 1 answer

I want to implement a search option on my Laravel application, but had this error:Class 'Illuminate\Support\Facades\Input' not found, I have tried to add this row at config/app like this:

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

Also at Controller I have added those rows:

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;

At Route I have added

Route::any('/search',function(){
    $image_tmp = $request->image;
    $fileName = time() . '.'.$image_tmp->clientExtension();
    $q = Input::get ( 'q' );
    $book = Book::where('title','LIKE','%'.$q.'%')->get();
    if(count($book) > 0)
        return view('home')->withDetails($book)->withQuery ( $q );
    else return view ('home')->withMessage('No Details found. Try to search again!');
});

But still it doesn't work.

Ad

Answer

Try this

config/app.php

use Request instead of Input

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

And your controller

use Illuminate\Http\Request;

and remove use Illuminate\Support\Facades\Input; top of your code

Ad
source: stackoverflow.com
Ad