I am new to laravel, I need to create a query for the db,
$query = Deal::query();
I want to use the wherehas operator. this is my code that is worked.
else if ($group_by == 'precedence') {
if($get_deals_for == 'noprecedence'){
$get_deals_for = 0;
}
$precedenceStatus = $get_deals_for;
$query-> where('precedence', '=', $precedenceStatus);
// \Log::info('The request precedence: '.$precedenceStatus);
}
I want to add this code also to the query
if($person) {
$query->whereHas('personnel', function ($subQuery) use ($person) {
$subQuery->where('id', '=', $person);
});
}
So I need to change the first code? how I can convert the first code to wherehas? the first code is from table called deal, the second section is from realtionship called personnel. the second section worked in other places in the code, I just need to fix the first section and not understand what to write in the use
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire