Laravel:根据输入参数选择结果

I have a search query in my controller

public function byQuery($query)
    {
        $q = $this->prepareQuery($query);
        if(str_contains($q,'zealand'))
        {
        $q = 'nz';
        }
        $titles = Title::where('suburb', 'LIKE', $q)
                                ->orWhere('postcode', 'LIKE', $q)
                                ->orWhere('title', 'LIKE', $q)
                                ->orWhere('country', 'LIKE', $q)
                                ->orWhere('state', 'LIKE', $q);

        if (isset($input['type']) && $input['type'] != '')
        {
            $titles = $titles->where('type', 'like', '%'. $input['type'].'%');
        } 
            $titles = $titles->orderBy('href', 'ASC')
                    ->orderBy(DB::raw('RAND()'))
                    ->paginate(36);

            return $titles;

    }

If I search for search like

search?q=new zealand

It will return all the results in my DB which match new zealand

If I search for

   search?q=new zealand&type=sold

I want if to return all the results from my DB which match new zealand and the type is sold.

So far it's not working. It only returns all the results from my DB and doesn't limit them to just the sold results.

$input is not defined (at least, I don't see it in the code you posted), so the isset() will always return false. Use the Input class, which already can do the checking:

if (Input::has('type'))
{
   $titles = $titles->where('type', 'like', '%'. rawurldecode(Input::get('type')).'%');
} 

Note: I added a rawurldecode() since from your example 'new zealand' would be passed down as 'new+zealand', and this needs be taken into account if you want it to match correctly.