I have a ProcessHistory and Person model I need a eloquent code for relation with multiple condition. Conditions: 1. oindex = oindex 2. pat_id = pat_id
I want a eloquent code to get result of the following sql code
select * from tbl_process_history as s join tbl_persons as p on (s.oindex = p.oindex and s.pat_id = p.pat_id)
I need to get all the persons having same oindex and pat_id. I have tried with below eloquent code where I can apply condition inside of relation 'own'. Here I can apply only for as static value.
ProcessHistory::with(['own'=>function($query){
return $query->where('pat_id','');
}])->get();
I need a condition inside of relation where I can match pat_id of process history model with persons model.