street-coder's avatar

How can i pass multiple where clause into eloquent query

having the below code but is returning empty json object

$cycle = $request->cycle; $day = $request->day; $Data = Cohort::where(['cycle' => $cycle, 'day' => $day]);

        return response()->json([
            'Message' => 'Data Retrieved Successfully',
            'Data' => $Data
        ], 200);
0 likes
1 reply
Nakov's avatar

but you are just making the query without executing it, you will have to append ->get() at the end so it returns results

$Data = Cohort::where(['cycle' => $cycle, 'day' => $day])->get();

or separate the where clauses:

$Data = Cohort::where('cycle', $cycle)->where( 'day', $day)->get();

Please or to participate in this conversation.