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

SimonAngatia's avatar

Illuminate\Http\Request::get(): Argument #1 ($key) must be of type string, null given Laravel Spatie Query Builder

I am using this https://github.com/protonemedia/inertiajs-tables-laravel-query-builder Laravel inertia Vue Js tables in my application. It works flawlessly on my local host but once I push the code to production, I get this error saying that Illuminate\Http\Request::get(): Argument #1 ($key) must be of type string, null given, called in /home/tiptime247/public_html/vendor/spatie/laravel-query-builder/src/QueryBuilderRequest.php on line 144

The code that is being highlighted as having an issue is ->defaultSort('name'):

 $games = QueryBuilder::for(IgslotGame::class)

            ->defaultSort('name')

            ->allowedSorts(['name', 'title', 'categories'])

            ->allowedFilters(['name', 'title', 'categories', $globalSearch])

            ->paginate(5)

            ->withQueryString();


Could someone help me know where the issue is? Thank you.

0 likes
1 reply
soul_sumy's avatar

Had the same issue. Config file was not loaded from package on staging server (locally all OK). I have no idea why this is happening. Fixed it by publishing config:

php artisan vendor:publish --provider="Spatie\QueryBuilder\QueryBuilderServiceProvider" --tag="query-builder-config"

Please or to participate in this conversation.