Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to use whereHas in laravel

//https://laravel.com/docs/9.x/queries#conditional-clauses

$result = $query
    ->where('precedence', '=', $precedenceStatus)
    ->when($person, function ($query) use ($person) {
        $query->whereHas('personnel', fn ($q) => $q->where('id', '=', $person));
    })
    ->get();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #whereHas #laravel
ADD COMMENT
Topic
Name
4+9 =