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

podu-file-plus's avatar

Query won't search for resulsts

Hi,

I have the below query which is not working for me. When I search for a string I sometimes get results back. I'm 100% sure by columns exist and the data si there. It seems that only results where the alias matches is working correctly for me.

public function index()
{
    $query = request('q');

    $itemsQuery = Item::query()

    if ($query !== null) {
        $monitorsQuery->where('url ', 'LIKE', '%' . $query . '%')
            ->orWhere('alias', 'LIKE', '%' . $query . '%');
    }

    $items = $itemsQuery->orderBy('alias')->paginate(self::PER_PAGE);
}

Does anybody understand what the problem could be?

0 likes
3 replies
bobbybouwmann's avatar
Level 88

There seems to be a space behind url . If you remove the space it should work as expected ;)

$monitorsQuery->where('url', 'LIKE', '%' . $query . '%')

Otherwise, there might be another issue.

podu-file-plus's avatar

I should hit myself in the face now for this error.

@bobbybouwmann Thanks for point out the space. The query is working correctly now.

Please or to participate in this conversation.