protected function editRouteForWeb() { //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/route/'; $stub_filename = 'route_for_web.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './routes/'; $output_filename = 'web.php'; //output(use OutputTrait) $this->outputAppend($output_path, $output_filename, $stub_compiled, $debug = false); }
private function start() { //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/controller/'; $stub_filename = 'app.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './app/Http/Controllers/'; $output_filename = $this->solveName($this->commandObj->argument('name'), config('CrudDscaffold.app_name_rules.app_controller_class')) . 'Controller.php'; //output(use OutputTrait) $this->outputPut($output_path, $output_filename, $stub_compiled, $debug = false); }
protected function start() { if ($this->commandObj->option('seeding')) { //(i)Factory -------------------------------------------------- //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/seed/'; $stub_filename = 'factory_apend.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = 'factory', $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './database/factories/'; $output_filename = 'ModelFactory.php'; //output(use OutputTrait) $this->outputAppend($output_path, $output_filename, $stub_compiled, $debug = false); //(ii)DatabaseSeeder -------------------------------------------------- //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/seed/'; $stub_filename = 'databaseSeeder_insert.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './database/seeds/'; $output_filename = 'DatabaseSeeder.php'; //replace word $pattern = '#(public function run\\(\\)\\s*{)(([^{}]*{[^}]*?}[^{}]*?)*)(.*?)(\\s*})#s'; //append at block end $replacement = '\\1\\2\\4' . $stub_compiled . '\\5'; //output(use OutputTrait) $this->outputReplace($output_path, $output_filename, $pattern, $replacement, $debug = false); //(iii)DatabaseSeeder -------------------------------------------------- //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/seed/'; $stub_filename = 'app.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './database/seeds/'; $output_filename = $this->solveName($this->commandObj->argument('name'), config('CrudDscaffold.app_name_rules.app_seeder_class')) . 'TableSeeder.php'; //output(use OutputTrait) $this->outputPut($output_path, $output_filename, $stub_compiled, $debug = false); } }
protected function start() { //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/migrate/'; $stub_filename = 'app.stub'; //set custom replace $custom_replace = ['table' => $this->solveName($this->commandObj->argument('name'), config('CrudDscaffold.app_name_rules.app_migrate_filename'))]; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = 'migration', $custom_replace); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './database/migrations/'; $output_filename = date('Y_m_d_His') . '_create_' . $this->solveName($this->commandObj->argument('name'), config('CrudDscaffold.app_name_rules.app_migrate_filename')) . '_table.php'; //output(use OutputTrait) $this->outputPut($output_path, $output_filename, $stub_compiled, $debug = false); }
private function start() { //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/view_app/'; $stub_filename = $this->viewName . '.stub'; //create custom parameter if ($schema = $this->commandObj->option('schema')) { $schemaArray = (new SchemaParser())->parse($schema); } $custom_replace = ['index' => ['search_fields' => (new SyntaxBuilder())->create($schemaArray, $this->commandObj->getMeta(), 'view-index-search'), 'header_fields' => (new SyntaxBuilder())->create($schemaArray, $this->commandObj->getMeta(), 'view-index-header'), 'content_fields' => (new SyntaxBuilder())->create($schemaArray, $this->commandObj->getMeta(), 'view-index-content')], 'show' => ['content_fields' => (new SyntaxBuilder())->create($schemaArray, $this->commandObj->getMeta(), 'view-show-content')], 'create' => ['content_fields' => ''], 'edit' => ['content_fields' => ''], 'duplicate' => ['content_fields' => ''], '_form' => ['content_fields' => (new SyntaxBuilder())->create($schemaArray, $this->commandObj->getMeta(), 'view-edit-content', true)], '_common' => []]; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace[$this->viewName]); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './resources/views/' . $this->solveName($this->commandObj->argument('name'), config('CrudDscaffold.app_name_rules.app_model_vars')) . '/'; $output_filename = $this->viewName . '.blade.php'; //output(use OutputTrait) $this->outputPut($output_path, $output_filename, $stub_compiled, $debug = false); }
protected function start() { //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/routeServiceProvider/'; $stub_filename = 'app.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './app/Providers/'; $output_filename = 'RouteServiceProvider.php'; //replace word $pattern = '#(public function boot\\(\\)\\s*{)(([^{}]*{[^}]*?}[^{}]*?)*)(.*?)(\\s*})#s'; //append at block end //$pattern = '#(.*)(public function boot\(Router \$router\)\n\s*\{\n)(.*?)(\s*}\n)(.*)#s'; //$replacement = '\1\2\3'."\n".$stub_compiled.'\4\5'; $replacement = '\\1\\2\\4' . $stub_compiled . '\\5'; //output(use OutputTrait) $this->outputReplace($output_path, $output_filename, $pattern, $replacement, $debug = false); }
protected function editModel_modelB2() { //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/relation/'; $stub_filename = 'model_B_add2.stub'; //set custom replace $custom_replace = ['relation_display_column' => $this->relation_display_column]; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './app/'; $output_filename = $this->model_B_name . '.php'; //replace word $pattern = '#(public function __construct\\(array \\$attributes = array\\(\\)\\)\\s*{)(([^{}]*{[^}]*?}[^{}]*?)*)(.*?)(\\s*})#s'; //append at block end $replacement = '\\1\\2\\4' . $stub_compiled . '\\5'; //output(use OutputTrait) $this->outputReplace($output_path, $output_filename, $pattern, $replacement, $debug = $this->debug); }
protected function start() { //(i)layout -------------------------------------------------- //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/view_layout/'; $stub_filename = 'layout.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './resources/views/'; $output_filename = 'layout.blade.php'; //output(use OutputTrait) $this->outputPutWithoutAlert($output_path, $output_filename, $stub_compiled, $debug = false); //(ii)error -------------------------------------------------- //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/view_layout/'; $stub_filename = 'error.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './resources/views/'; $output_filename = 'error.blade.php'; //output(use OutputTrait) $this->outputPutWithoutAlert($output_path, $output_filename, $stub_compiled, $debug = false); //(iii)navi - put -------------------------------------------------- //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/view_layout/'; $stub_filename = 'navi.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './resources/views/'; $output_filename = 'navi.blade.php'; //output(use OutputTrait) $this->outputPutWithoutAlert($output_path, $output_filename, $stub_compiled, $debug = false); //(iv)navi - add -------------------------------------------------- //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/view_layout/'; $stub_filename = 'navi_add.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './resources/views/'; $output_filename = 'navi.blade.php'; //replace word $pattern = '#(<ul id="app_navi" class="dropdown-menu" role="menu">)(.*?)(\\s*?</ul>)#s'; $replacement = '\\1\\2' . $stub_compiled . '\\3'; //output(use OutputTrait) $this->outputReplace($output_path, $output_filename, $pattern, $replacement, $debug = false); //(v)navi - add2 -------------------------------------------------- //get_stub_path and filename $stub_path = __DIR__ . '/../Stubs/view_layout/'; $stub_filename = 'navi_add2.stub'; //create new stub $stub = new StubController($this->commandObj, $this->files, $stub_path . $stub_filename, $schema_repalce_type = null, $custom_replace = null); //compile $stub_compiled = $stub->getCompiled(); //get output_path and filename $output_path = './resources/views/'; $output_filename = 'navi.blade.php'; //replace word $pattern = '#({{-- include_area_app_common_end --}})#s'; $replacement = $stub_compiled . '\\1'; //output(use OutputTrait) $this->outputReplace($output_path, $output_filename, $pattern, $replacement, $debug = false); }