Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #19 from Naoray/dev
Browse files Browse the repository at this point in the history
prevent printing wrong information
  • Loading branch information
Naoray authored Sep 7, 2019
2 parents f608ff1 + 0915e2c commit 6354ea6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Commands/PrefillFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public function handle()
->values()
->all();

$this->writeFactoryFile($factoryPath, $columnData, $modelClass);
$this->info('Factory blueprint created!');
if ($this->writeFactoryFile($factoryPath, $columnData, $modelClass)) {
$this->info('Factory blueprint created!');
}
}

/**
Expand Down Expand Up @@ -385,11 +386,15 @@ protected function qualifyClass($name)
*
* @param string $path
* @param array $data
*
* @return bool
*/
protected function writeFactoryFile($path, $data, $modelClass)
{
if (0 === count($data)) {
return $this->error('We could not find any data for your factory. Did you `php artisan migrate` already?');
$this->error('We could not find any data for your factory. Did you `php artisan migrate` already?');

return false;
}

$content = $this->laravel->view->make('prefill-factory-helper::factory', [
Expand All @@ -398,5 +403,7 @@ protected function writeFactoryFile($path, $data, $modelClass)
])->render();

File::put($path, "<?php\n\n" . $content);

return true;
}
}

0 comments on commit 6354ea6

Please sign in to comment.