/** * Execute the console command. * * @return mixed */ public function handle() { if (File::exists(Config::publishedSeederRealpath())) { if (!$this->confirm('The seeder file already exists, overwrite it? [Yes|no]')) { $this->line(''); return $this->info('Okay, no changes made to the file.'); } } // Laravel 5.0 does not have make:seed command // in that case ignore the command and copy the contents // of the file directly. try { $this->callSilent('make:seed', ['name' => Config::seederNameKey()]); } catch (\Exception $ex) { } $inputFile = file_get_contents(Config::localSeederPath()); $outputFile = fopen(Config::publishedSeederRealpath(), 'w'); if ($inputFile && $outputFile) { fwrite($outputFile, $inputFile); fclose($outputFile); } else { File::delete(Config::publishedSeederRealpath()); $this->line(''); return $this->error('There was an error creating the seeder file, ' . 'check write permissions for database/seeds directory' . PHP_EOL . PHP_EOL . 'If you think this is a bug, please submit a bug report ' . 'at https://github.com/moharrum/laravel-geoip-world-cities/issues'); } $this->line(''); $this->info('Okay, seeder file created successfully.'); }
/** * Returns an array containing the full path to each dump file. * * @return array */ private function dumpFiles() { $files = []; foreach (File::allFiles(Config::dumpPath()) as $dumpFile) { $files[] = $dumpFile->getRealpath(); } sort($files); return $files; }
/** * Execute the console command. * * @return mixed */ public function handle() { if (File::exists(Config::publishedMigrationRealpath())) { if (!$this->confirm('The migration file already exists, overwrite it? [Yes|no]')) { $this->line(''); return $this->info('Okay, no changes made to the file.'); } } $inputFile = file_get_contents(Config::localMigrationRealpath()); $outputFile = fopen(Config::publishedMigrationRealpath(), 'w'); if ($inputFile && $outputFile) { fwrite($outputFile, $inputFile); fclose($outputFile); } else { File::delete(Config::publishedSeederRealpath()); $this->line(''); return $this->error('There was an error creating the migration file, ' . 'check write permissions for database/migrations directory' . PHP_EOL . PHP_EOL . 'If you think this is a bug, please submit a bug report ' . 'at https://github.com/moharrum/laravel-geoip-world-cities/issues'); } $this->line(''); $this->info('Okay, migration file created successfully.'); }
/** * Create a new City instance. * * @param array $attributes */ public function __construct(array $attributes = []) { parent::__construct($attributes); $this->table = Config::citiesTableName(); }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::drop(Config::citiesTableName()); }
/** * Merges user's and cities's configs. */ private function mergeConfig() { $this->mergeConfigFrom(Config::localConfigRealpath(), Config::configKey()); }