예제 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     parent::handle();
     if (!$this->fields) {
         throw new \InvalidArgumentException('Fields must be supplied');
     }
     // Make View Files
     // MASTER FILE
     $m = new Mustache_Engine();
     $master_file = $m->render($this->getStub('views/master'), $this->variables);
     $path = str_replace('.', '/', $this->view);
     // Store View File
     $master_file_name = base_path('resources/views/crud_layout/master.blade.php');
     if ($this->putFile($master_file_name, $master_file)) {
         $this->info('Layout-file created');
     } else {
         $this->warn('Canceled.');
     }
     $this->createForm();
     $this->putFile(base_path('resources/views/' . $path . '/form.blade.php'), $this->form_html);
     foreach ($this->views as $view) {
         $file = $m->render($this->getStub('views/' . $view), $this->variables);
         $file_name = base_path('resources/views/' . $path . '/' . $view . '.blade.php');
         if ($this->putFile($file_name, $file)) {
             $this->info($view . '-file created');
         } else {
             $this->warn('Canceled.');
         }
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     parent::handle();
     // Make Controller File
     $m = new Mustache_Engine();
     $controller_file = $m->render($this->getStub('Controller'), $this->variables);
     // Store Controller File
     $controller_file_name = app_path('Http/Controllers/' . $this->resource . 'Controller.php');
     $this->putFile($controller_file_name, $controller_file);
     $this->info($this->resource . 'Controller created.');
     $this->info('Add the following to your routes.php file:');
     $route = str_replace('.', '/', $this->route);
     $this->question("Route::resource('" . $route . "', '" . $this->resource . "Controller');");
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     parent::handle();
     $m = new Mustache_Engine();
     // Make Model File
     $controller_file = $m->render($this->getStub('Model'), $this->variables);
     // Store Model File
     $controller_file_name = app_path($this->resource . '.php');
     $this->putFile($controller_file_name, $controller_file);
     $this->info('Model ' . $this->resource . ' created.');
     // Make Migration File
     $migration_file = $m->render($this->getStub('Migration'), $this->variables);
     // Store Model File
     $path = date('Y_m_d_His_') . 'create_' . $this->table . '_table.php';
     $migration_file_name = database_path('migrations/' . $path);
     $this->putFile($migration_file_name, $migration_file);
     $this->info('Migration for ' . $this->resource . ' created.');
 }