Example #1
0
 public function newController($path, $controller)
 {
     $namespace = $this->utils->dosPath($this->utils->dirname($controller));
     $class = $this->utils->filename($controller);
     if ($this->writer->write($path, ['namespace' => $namespace === '.' ? '' : "\\{$namespace}", 'class' => $class])) {
         require_once $path;
     }
 }
Example #2
0
 public function write()
 {
     $pdo = $this->database->getConnection();
     $tables = $pdo->select(sprintf("SELECT TABLE_NAME as `table`, COLUMN_NAME as pk FROM information_schema.columns WHERE table_schema = '%s' AND COLUMN_KEY = 'PRI'", $pdo->getDatabaseName()));
     foreach ($tables as $table) {
         $name = $table->table;
         if (!$this->resolver->getModel($name)) {
             $path = sprintf('%s/app/Model/%s.php', $this->bootLoader->getBaseDir(), ucfirst(Str::camel(Str::singular("{$name}"))));
             if (!file_exists($path)) {
                 $this->writer->write($path, ['class' => $this->utils->filename($path), 'table' => $table->table, 'pk' => $table->pk], 'Created new model');
             }
         }
     }
 }