79648747

Date: 2025-06-02 12:49:38
Score: 1
Natty:
Report link
return User::join('personal_info','users.id','=','personal_info.user_id')
    ->leftJoin('user_data', function ($q) use ($filters) {
        $q->on('users.id', '=','user_data.user_id');
        foreach ( $filters as $field => $value ) {
            $q->where($field,'=',$value)
        }
    });

This will specifically add the filters to the join i.e. leftJoin t2 on t1.1 = t2.2 AND filter = val
In this way you can join the specific records that match all filters applied

Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: theistand