Omosanya Olamilekan
Published in : 2022-03-16
HERE IS MY CONTROLLER : HomeController
usertype=='1') { return view('admin.home'); } if (Auth::user()->usertype=='0') { return view('dashboard'); } else { return index()->back(); } } public function index() { return view('welcome'); } // functions for state.lg... public function getStates(){ $states = State::all()->pluck('state_name','id'); return view('auth/register', ['states' => $states]); } public function getLocalgovernments($id){ $localgovernment= Localgovernment::where('state_id',$id)->pluck('LocalGovernment_name','id'); return json_encode($localgovernment); } public function getWards($id){ $wards= Ward::where('LocalGovernment_id',$id)->pluck('ward_name','id'); return json_encode($wards); } public function getPollingunits($id){ $pollingunits= Pollingunit::where('LocalGovernment_id',$id)->pluck('PollingUnits_name','id'); return json_encode($pollingunits); } }
and my web.php page code is:
get('/dashboard', function () { return view('dashboard');})->name('dashboard');
this is my register.blade.php
DropDown Feature Select your State Select State @foreach( $states as $key => $value) {{$value}} @endforeach Select your LG Select State Select your Wards Select City Select your Poll-units Select PollingUnits $(document).ready(function(){ $('select[name="state"]').on('change',function(){ var state_id= $(this).val(); if (state_id ) { $.ajax({ url: "{{url('/ getLocalgovernments/')}}/"+state_id, type: "GET", dataType: "json", success: function(data){ console.log(data); $('select[name="LocalGovernment"]').empty(); $.each(data,function(key,value){ $('select[name="LocalGovernment"]').append(''+value+''); }); } }); }else { $('select[name="LocalGovernment"]').empty(); } }); $('select[name="LocalGovernment"]').on('change',function(){ var LocalGovernment_id= $(this).val(); if (LocalGovernment_id) { $.ajax({ url: "{{url('/getWards/')}}/"+LocalGovernment_id, type: "GET", dataType: "json", success: function(data){ console.log(data); $('select[name="Ward"]').empty(); $.each(data,function(key,value){ $('select[name="Ward"]').append(''+value+''); }); } }); }else { $('select[name="Ward"]').empty(); } }); $('select[name="PollingUnits"]').on('change',function(){ var PollingUnits_id= $(this).val(); if (PollingUnits_id) { $.ajax({ url: "{{url('/getPollingunits/')}}/"+PollingUnits_id, type: "GET", dataType: "json", success: function(data){ console.log(data); $('select[name="Ward"]').empty(); $.each(data,function(key,value){ $('select[name="Ward"]').append(''+value+''); }); } }); }else { $('select[name="Ward"]').empty(); } }); });
please any help will be appreciated
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
Mohamed Atef Date : 2022-03-16
Best answers
51
Best answers
51
Hello Omosanya, Welcome to Web-Brackets.com
I have some doubts that if you tried auth.register instead of auth/register this might help
and PLEASE share the routes.php file because it seems that you are not connecting the Route to the correct function
Omosanya Olamilekan Date : 2022-03-17
this is my routeServiceProvider.php
Thanks Sir
Mohamed Atef Date : 2022-03-17
Sorry I mean web.php
Omosanya Olamilekan Date : 2022-03-17
Best answers
1
Best answers
1
it is not showing the error again.
thanks a lot, Sir. But I am having an issue with my ajax. it's showing 500 (Internal Server Error). this is my code: