public function fire()
{
$filename = $this->option('filename');
$this->dirs = $this->option('dir');
$model = $this->argument('model');
$ignore = $this->option('ignore');
$this->reset = $this->option('reset');
try {
$this->existingFactories = $this->files->get($filename);
} catch (FileNotFoundException $e) {
$this->existingFactories = '';
}
$result = $this->generateFactories($model, $ignore);
$written = $this->files->put('database/factories/ModelFactory.php', $result);
if ($written !== false) {
$this->info("Model factories were written successfully to " . $filename);
} else {
$this->error("Failed to write model factories to " . $filename);
}
}