/** * 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.'); }