modifyQueryUsing ->join changes $record->id
Building a Dashboard widget to display Team Notes.
Works except using join or leftJoin changes $record->id from the original query table to the "joined" table.
I want to use the original table id for a link to the record and it changes to the id of the "joined' table .
Solution:Jump to solution
How about this?
Basically flipped the logic, and used a whereHas instead of the join to do some of the logic.
```
return $table
->query(Persona::query())...
2 Replies
Solution
How about this?
Basically flipped the logic, and used a whereHas instead of the join to do some of the logic.
This is very promising . The vars
$client_id,$csm_id, $am_id
are Undefined in the if statements that contain the where, whereHas . I just had to change to ->modifyQueryUsing(function(Builder $query) use ($client_id,$csm_id, $am_id) {
adding the use
and change $query->whereHas('users',
to $query->whereHas('client',
to fit my models. (for other readers benefit).
Thanks that worked!