Show only related data in search filter

Posted 3 months ago by shahzadsarwar

trying to apply a search filter.

$streets = (new PropertyStreet)->newQuery();

    if ($request->has('street')) {
        $streets->where('name', 'like', '%'.$request->street.'%');
    }

    if ($request->has('house')) {
        $streets->whereHas('properties', function ($query) use ($request) {
            $query->where('house_number', $request->house);
        });
    }

    return $streets->get();

it gets the street data I want to do something like this ?street=b-34&house=21 and to display the house data, only as of right now it get's only street.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.