I have some error, page 293 (CitiesTableSeeder.php),
error Unknown column 'city_name' in 'field list',
We can change code CitiesTableSeeder.php.
Change 'city_name' to 'city' following structure in migration file ..._create_cities_table.php
public function run(){$url_city = "https://api.rajaongkir.com/starter/city?key=API_KEY";$json_str = file_get_contents($url_city);$json_obj = json_decode($json_str);$cities = [];foreach($json_obj->rajaongkir->results as $city){$cities[] = ['id' => $city->city_id,'province_id' => $city->province_id,'city' => $city->city_name,'type' => $city->type,'postal_code' => $city->postal_code,];}DB::table('cities')->insert($cities);}
I have some error, page 293 (CitiesTableSeeder.php), error Unknown column 'city_name' in 'field list',
We can change code CitiesTableSeeder.php. Change 'city_name' to 'city' following structure in migration file ..._create_cities_table.php
public function run()
{
$url_city = "https://api.rajaongkir.com/starter/city?key=API_KEY";
$json_str = file_get_contents($url_city);
$json_obj = json_decode($json_str);
$cities = [];
foreach($json_obj->rajaongkir->results as $city){
$cities[] = [
'id' => $city->city_id,
'province_id' => $city->province_id,
'city' => $city->city_name,
'type' => $city->type,
'postal_code' => $city->postal_code,
];
}
DB::table('cities')->insert($cities);
}