/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $modelsOnly = (bool) $this->option('models-only');
     $dryRun = (bool) $this->option('dry-run');
     $interactive = !(bool) $this->option('auto');
     $this->listenForLogEvents();
     $generator = new Generator(!$dryRun, $this);
     $generator->generate();
     $this->info('Done.');
 }
 /**
  * @param bool    $write    whether to write files; if false, just outputs analyzed data
  * @param Command $command  the console command, if it was called from console
  */
 public function __construct($write = true, Command $command = null)
 {
     parent::__construct($write, $command);
     $this->analyzer = new Analyzer($command);
     $this->modelWriter = new ModelWriter();
     //$this->repositoryWriter = new RepositoryWriter();
 }
 /**
  * @test
  */
 function it_generates_models()
 {
     $pxlcms = new Generator();
     $pxlcms->generate();
     $models = ['Page', 'PageTranslation', 'Slug', 'News', 'NewsTranslation'];
     /** @var Filesystem $files */
     $files = $this->app['files'];
     // check if files were created and whether the content matches
     // what was pre-generated since we cannot actually load the run-time
     // generated models, this is as far as the test can go. We can
     // separately test the actual pre-generated models later, since they
     // were tested to be the same.
     foreach ($models as $model) {
         $file = $this->generatedPath . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR . $model . '.php';
         $this->assertTrue($files->exists($file), "model file should exist");
         $pregeneratedFile = $this->getGeneratedContentPath() . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR . $model . '.php';
         $this->assertEquals($files->get($pregeneratedFile), $files->get($file), "The generated content for model '{$model}' does not match the pregenerated file.");
     }
 }