Sinres

How search for multiple words in Eloquent?

Posted 4 months ago by Sinres

Hello Guys,

This is my code for search phrase but I don't know how I can make search for multiple words. Any ideas?

public function searchRecord()
    {
        $searchPhrase = Input::get('q');
        
        $deviceInspections = DeviceInspection::whereHas('sale', function($query) use($searchPhrase) {
            return $query->where('sale_number', 'like', '%'.$searchPhrase.'%');
        })->with(['sale' => function($query) use($searchPhrase) {
            $query->where('sale_number', 'like', '%'.$searchPhrase.'%');
        }])->paginate(20);

        return view('device_inspections.index', compact('deviceInspections', 'searchPhrase'));
    }

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