mardi 28 février 2017

Laravel search mutiple fields

i currently have a search function on my website, i need it to search 3 fields - appid, mobilenumber, email .

Right now once the user enters the data in the search box it searches all 3 but its not working.

Data is collected using GET.

Here is my query

http://ift.tt/2mzXaST

    $mobile = INPUT::get('searchall');
    $email = INPUT::get('searchall');
    $appid = INPUT::get('searchall');

$data = DB::table('leads')
->when($mobile, function($query) use ($mobile){
                return $query->where('MobilePhone', $mobile);
            })

            ->when($email, function($query) use ($email){
                return $query->where('Email', $email);
            })

            ->when($appid, function($query) use ($appid){
                return $query->where('AppID', $appid);
            })

->get();

So i need it to search each field until it finds the correct field value.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l7KsOa
via IFTTT

Aucun commentaire:

Enregistrer un commentaire