Hi I have table that contain two foreign key as below.
symptom_diseases table
disease_id symptom_id
1 1
1 2
2 1
2 3
I would like to query with symptom_id array and return disease_id array. For example
symptom_id array = [1] then return disease_id [1,2]
symptom_id array = [1,2] then return disease_id [1]
symptom_id array = [1,3] then return disease_id [2]
symptom_id array = [2,3] then return null
I try to query using
whereIn
$diseaseArr = SymptomDisease::whereIn('symptom_id',$request->symptom)->pluck('disease_id')->toArray();
but I got wrong result. Any advice or guidance on this would be greatly appreciated, Thanks.
$request->symptomactually contains?