| @@ 9-30 (lines=22) @@ | ||
| 6 | use Webfactor\Laravel\Generators\Contracts\ServiceInterface; |
|
| 7 | use Webfactor\Laravel\Generators\Traits\CanGenerateFile; |
|
| 8 | ||
| 9 | class FactoryService extends ServiceAbstract implements ServiceInterface |
|
| 10 | { |
|
| 11 | use CanGenerateFile; |
|
| 12 | ||
| 13 | protected $key = 'factory'; |
|
| 14 | ||
| 15 | public function getConsoleOutput() |
|
| 16 | { |
|
| 17 | return 'Generated factory file: '.$this->command->naming[$this->key]->getRelativeFilePath(); |
|
| 18 | } |
|
| 19 | ||
| 20 | protected function buildFileContent() |
|
| 21 | { |
|
| 22 | $this->replaceModelRelatedStrings(); |
|
| 23 | } |
|
| 24 | ||
| 25 | protected function replaceModelRelatedStrings() |
|
| 26 | { |
|
| 27 | $this->fileContent = str_replace('__model_namespace__', $this->command->naming['crudModel']->getNamespace(), $this->fileContent); |
|
| 28 | $this->fileContent = str_replace('__model_class__', $this->command->naming['crudModel']->getClassName(), $this->fileContent); |
|
| 29 | } |
|
| 30 | } |
|
| 31 | ||
| @@ 9-30 (lines=22) @@ | ||
| 6 | use Webfactor\Laravel\Generators\Contracts\ServiceInterface; |
|
| 7 | use Webfactor\Laravel\Generators\Traits\CanGenerateFile; |
|
| 8 | ||
| 9 | class SeederService extends ServiceAbstract implements ServiceInterface |
|
| 10 | { |
|
| 11 | use CanGenerateFile; |
|
| 12 | ||
| 13 | protected $key = 'seeder'; |
|
| 14 | ||
| 15 | public function getConsoleOutput() |
|
| 16 | { |
|
| 17 | return 'Generated seeder: '.$this->command->naming[$this->key]->getRelativeFilePath(); |
|
| 18 | } |
|
| 19 | ||
| 20 | protected function buildFileContent() |
|
| 21 | { |
|
| 22 | $this->replaceClassName(); |
|
| 23 | $this->replaceModelRelatedStrings(); |
|
| 24 | } |
|
| 25 | ||
| 26 | protected function replaceModelRelatedStrings() |
|
| 27 | { |
|
| 28 | $this->fileContent = str_replace('__model_namespace__', $this->command->naming['crudModel']->getNamespace(), $this->fileContent); |
|
| 29 | $this->fileContent = str_replace('__model_class__', $this->command->naming['crudModel']->getClassName(), $this->fileContent); |
|
| 30 | } |
|
| 31 | } |
|
| 32 | ||