$data = EmpData::leftJoin('states', 'states.id', 'emp_data.empState')
->leftJoin('districts', 'districts.id', 'emp_data.empDistrict')
->selectRaw('emp_data.*, states.name as stateName')
->selectRaw('emp_data.*, districts.name as districtName')
->paginate(30);
In my model 'EmpData' I contain state id and district id, and the 'state' & 'district' table includes the name of the state or district. so I use left join. Data fetch correctly, but it returns 4 times data, how can I fix it.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/w3U94sD
via IFTTT
Aucun commentaire:
Enregistrer un commentaire