mardi 10 mars 2020

How to write this query in laravel? Any Suggestions?

This is the Query which is working fine in MY SQL:

SELECT users.name FROM ((event_user INNER JOIN events ON event_user.event_id = events.id) INNER JOIN users ON event_user.user_id = users.id) where events.name like '%FEB%' or users.name like '%FEB%' or users.email like '%FEB%' or users.phone like '%FEB%'

This is what I've written which is of course not working:

$data['search_data'] = EventUser::select('users.*')
        ->join
            ('users', 'event_user.user_id', '=', 'users.id')
        ->join
            ('events', 'event_user.event_id', '=', 'events.id')
        ->where
            ('events.name','like', "'$search'")
        ->orWhere
            ("users.id",'like', "'$search'")
        ->orWhere
            ("users.name",'like', "'$search'")
        ->orWhere
            ("users.phone",'like', "'$search'")
        ->orWhere
            ("users.email",'like', "'$search'")
        ->orWhere
            ("users.password",'like', "'$search'")
        ->orWhere
            ("users.work_location",'like', "'$search'")
        ->orWhere
            ("users.profession",'like', "'$search'")
        ->orWhere
            ("users.designation",'like', "'$search'")
        ->orWhere
            ("users.committee",'like', "'$search'")
        ->orWhere
            ("users.role",'like', "'$search'")
        ->orWhere
            ("users.bio",'like', "'$search'")
        ->paginate(10);


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

Aucun commentaire:

Enregistrer un commentaire