I have table named projectlist as below. I would like to get list of cities from each country & list of projects from each city
-Country City Project -India Chennai Project1 India Hyderabad Project2 India Delhi Project3 India Mumbai Project4 India Bangalore Project5 USA Shreveport Project6 USA Chicago Project7 USA New York Project8 USA Huston Project9 Germany Berlin Project10 Germany Munich Project11 Germany Framkfurt Project12 India Hyderabad Project13 India Bangalore Project14 USA Shreveport Project15 Germany Berlin Project16 Germany Munich Project17
I have the below code in my laravel controller. I know that the below code is a wrong approach, please guide me with sample codes. And I would like to return this value and display in blade view
$data4 = DB::table('loksabha2014')
->select(
DB::raw('alliance as alliance','partyname as partyname'),
DB::raw('count(*) as number'))
->groupBy('alliance')
->get();
I would like to display as below in my blade view
Cities List:
India - Chennai, Hyderabad, Delhi, Mumbai, Bangalore
USA - Shreveport, Chicago, New York, Huston
Germany - Berlin, Munich, Framkfurt
Project List:
Chennai - Project1
Hyderabad - Project2, Project13
Delhi - Project3
Bangalore - Project14
Shreveport - Project6, Project15
Chicago - Project7
New York - Project8
Huston - Project9
Berlin - Project10, Project16
Munich - Project11, Project17