Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

o227786060@gmail.com's avatar

Non-static method Illuminate\Http\Request::input() cannot be called statically

Build Modern Laravel Apps Using Inertia.js EPISODE-17 Filtering, State, and Query Strings 07:30

The following error occursWhat details should I pay attention to Can someone point me? thanks!

Error Non-static method Illuminate\Http\Request::input() cannot be called statically

routes ->web

Route::get('/users', function () { return Inertia::render('Users', [ 'users' => User::query() ->when(Request::input('search'), function($query,$search){ $query->where('name', 'like',"%{$search}%"); })

    ->paginate(10)
    ->through(fn($user) => [
        'id' => $user->id,
        'name' => $user->name
    ]),


]);

});

0 likes
4 replies
Bookamat's avatar

@o227786060@gmail.com In most cases the Facade needs to be called for these magic methods.

Import this one

Illuminate\Support\Facades\Request::input('search')
1 like
MichalOravec's avatar
Level 75

Instead of

use Illuminate\Http\Request;

use

use Illuminate\Support\Facades\Request;
1 like

Please or to participate in this conversation.