/** * Run the database seeds. * * @return void */ public function run() { $location = \Issue\Location::create(['parent_id' => 0]); $locationNames = ['ro' => 'Locatii', 'en' => 'Locations']; foreach (['ro', 'en'] as $locale) { $location->translateOrNew($locale)->name = $locationNames[$locale]; } $location->save(); }
protected function importLocations() { $location = Location::create(['parent_id' => 0]); $locationNames = ['ro' => 'Locatii', 'en' => 'Locations']; foreach (['ro', 'en'] as $locale) { $location->translateOrNew($locale)->name = $locationNames[$locale]; } $location->save(); $locations = DB::connection('oldissue')->select('select * from lexlocation'); foreach ($locations as $location) { $newLocation = new Location(); $newLocation->id = $location->id + 1; $newLocation->parent_id = $location->parentid + 1; $translatableData = ['ro' => ['name' => $location->name ? $location->name : ''], 'en' => ['name' => $location->enname ? $location->enname : '']]; $newLocation->fill($translatableData); $newLocation->save(); } return print_r('Au fost importate: ' . Location::count() . ' locatii procedurale.' . "\n"); }