This video helped me to achieve what I wanted to do!
its not working 100%
change the code of the video to this then it will work
public function dynamicDropdown() {
$countrylist = DB::table('dynamicdropdown')->select('Country')->groupBy('Country')->get();
return view('dynamicdropdown')->with('countrylist', $countrylist);
}
function fetch(Request $request)
{
$select = $request->get('select');
$value = $request->get('value');
$dependent = $request->get('dependent');
$data = DB::table('dynamicdropdown')
->where($select, $value)
->select($dependent)
->groupBy($dependent)
->get();
$output = '<option value="">Select '.ucfirst($dependent).'</option>';
foreach($data as $row)
{
$output .= '<option value="'.$row->$dependent.'">'.$row->$dependent.'</option>';
}
echo $output;
}
Change like this and it will work, you have to use select method,