I have two select option field in a from, one for the province and one for the city. There are two tables which corresponds to this fields.
//The province table schema
Schema::create('provinces', function (Blueprint $table) {
$table->increments('id');
$table->string('province', 100);
$table->timestamps();
//The city table schema
Schema::create('cities', function (Blueprint $table) {
$table->increments('id');
$table->string('city', 20);
$table->smallInteger('province_id')->unsigned();
$table->index('province_id');
$table->timestamps();
These tables are pre-populated with the name of provinces, cities and their related province id. In my form I need that after selecting a province, the city field be updated with a list of that province cities. How can I do this?
//The create method in controller
public function create()
{
$provinces=Province::lists('province', 'id')->all();
$cities=City::lists('city', 'id');
return view('profile.create', compact('provinces', 'cities'));
}