mardi 25 juillet 2017

How can we write multiple column search with the help of laravel and mongo?

In my laravel project, I have search field in listing page to search email, firstname and lastname but when I type firstname and lastname sometimes result is not getting. Database I am using is mongo. I am using a package to connect mongo "http://ift.tt/1qxFWF0". I think for better result we need to use raw method right? If so how can I add mongo query with raw(). Please help me I am a beginner in mongo.

$users     = Userlist::select('_id', 'usrEmail', 'usrFirstname', 'usrLastname')
                        ->where(function($query) use ($search) {
                            $query->where('usrEmail', 'like', "%{$search}%")
                                ->orWhere('usrFirstname', 'like', "%{$search}%")
                                ->orWhere('usrLastname', 'like', "%{$search}%");
                        })
                        ->skip($start)
                        ->take($limit)
                        ->orderBy($order, $dir)
                        ->get();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire