1001 0 0 0
Last Updated : 2023-12-10 01:16:03
Some times you will need to create an eloquent where clause and inside that where you may need to add extra or where claused
Model::where(function ($query) use ($a,$b) {
$query->where('a', '=', $a)
->orWhere('b', '=', $b);
})
->where(function ($query) use ($c,$d) {
$query->where('c', '=', $c)
->orWhere('d', '=', $d);
});
//------------------------------ Another Example
$committeeTest = CommitteeModel::where("id","!=", $id)->where(function($q) use($name, $acronym){
$q->where("name",$name)->orwhere("acronym",$acronym);
})->first();
Example#2
$allCommitteeDocs = GovernmentResponsesModel::where('date', '>=', "$dateLimit")->with(['committee'])
->whereHas(
'committee',function($billQ2) use ($memberId){
$billQ2
->whereHas(
'favorites',function($favoritesQ) use ($memberId) {
$favoritesQ->where('user_id',$memberId)
//->where('favorites.entity_type',"committee")
->whereIn('entity_type',['committee', 'provincialcommittee'])
/* ->where(function($committeeQ) {
$committeeQ->where('favorites.entity_type',"committee")
->orWhere('favorites.entity_type',"provincialcommittee");
}) */
;
}
);
}
)
->orderBy('updated_at','desc')
->get()
->unique('committee_id')
->toArray();