Skip to content
Advertisement

two condition in same query laravel

here is what I want check rows with ( user_id AND member_name) I have try some other code and in this one I got this error “message”:”mb_strpos() expects parameter 1 to be string, object given”

$checkData= DB::table('member_opinions')
    ->where(DB::table('member_opinions')
        ->where('user_id',$members->user_id)
    )
    ->orWhere( DB::table('member_opinions')
        ->where('member_name',$request->{'committees_name'})
    )
    ->first();
 /* $checkData= DB::table('member_opinions')
    ->where('user_id',$members->user_id)
    ->orWhere('member_name',$request->{'committees_name'})
    ->first();
 */

How can I do it?

Advertisement

Answer

$checkData= DB::table('member_opinions')
    ->where('user_id',$members->user_id)
    ->orWhere('member_name',$request->{'committees_name'})
    ->first();

Let me know did it works.

Update:

Try it out if you want and operation

$checkData= DB::table('member_opinions')
    ->where('user_id',$members->user_id)
    ->where('member_name',$request->{'committees_name'})
    ->first();

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement