Route::get('/test22', function() { $all_c = \AddrCountryConsulate::all(); $i = 0; foreach ($all_c as $c) { /* $country = \AddrCountry::where('title_ru', $c->country)->first(); if ($country) { $c->country_id = $country->country_id; $c->save(); //echo ' - '.$country->country_id; } else { echo $c->country; } echo '
'; if ($c->country_id != 0) { $city = \AddrCity::where('title_ru', $c->city)->where('country_id', $c->country_id)->first(); if ($city) { $c->city_id = $city->city_id; $c->save(); echo $i++.'
'; } }*/ } });