You can add where clause to a model like ->where(/*condition*/)
User::where('status' ,'=' ,1)->where('payment', '=' ,1)->get();
Sometimes We need to add orWhere condition to our queries, between two cases. This might interfere with other conditions so we need to pass them in a function.
->where( function($query) {
$query->where('parent_id', '=', 1)
->orWhere('parent_id','=' ,2);
} )
To get external variables pass them with use
->where( function($query) use ($case1, $case2) {
$query->where('parent_id', '=', $case1)
->orWhere('parent_id', '=' ,case2);
} )
Good post. I definitely appreciate this site.
Thanks!