laravel-vue-book / be-fullstack-developer

Update Be Fullstack Developer
MIT License
7 stars 3 forks source link

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'city_name' in 'field list' #2

Closed dedihartono closed 6 years ago

dedihartono commented 6 years ago

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); }