URL ending with a question mark

When having a page using a search filter, on the first load, there’s a questionmark ending the url like:

/customer/dashboard?

The page has a public $search variable and is added to the $queryString variable. The default value of $search = null;

class Projects extends Component
{
    use WithPagination;

    public $search;
    protected $user;
    protected $projects;
    public $queryString = ['search'];

    ...
}

Is there some way, when no attributes are given, the url doesn’t show the question mark at the end of the url?

Hey, @voicecode-bv

Can you show us the complete code? (e.g: search route, search method …)

Hi @skywalker,

No need, I just received an answer. Looks like you can modify the behaviour of $queryString.

 public function getQueryString()
    {
        return array_merge([
            'page' => ['except' => 1],
            'search' => [
                'except' => null,
                'except' => '',
            ],
        ], $this->queryString);
    }

That’s Great! Good to know.