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.