public function fire() { $folder = Folder::load(database_path('/migrations'), true, 0755); $dontRenderTrigger = !!$this->input->getOption('without-trigger'); if (!$dontRenderTrigger) { File::load($folder->pwd() . '/' . date('Y_m_d_His', time()) . '_create_timestsmp_renew_trigger_function.php', true, 0755, 0644)->write(view('cmf::install.db.create_timestsmp_renew_trigger_function_migration')->render()); } File::load($folder->pwd() . '/' . date('Y_m_d_His', time() + 1) . '_create_admins_table.php', true, 0755, 0644)->write(view('cmf::install.db.create_admins_table_migration', ['withoutTrigger' => $dontRenderTrigger])->render()); $this->line('Done'); $this->line('Run [artisan migrate] (and [composer dump-autoload] if migration classes not found)'); }
public function fire() { $appSubfolder = ucfirst(trim(trim($this->input->getArgument('app_subfolder')), '/\\')); $lowercasedSubfolder = snake_case($appSubfolder); $folderPath = app_path('/' . $appSubfolder); if (Folder::exist($folderPath)) { $this->line('Terminated. Folder [' . $folderPath . '] already exist'); } $folder = Folder::load($folderPath, true, 0755); $dataForViews = ['sectionName' => $appSubfolder, 'urlPrefix' => trim(trim($this->input->getArgument('url_prefix'), '/\\')), 'dbClassesAppSubfolder' => $this->input->getArgument('database_classes_app_subfolder')]; // create site loader $file = File::load($folder->pwd() . '/' . $appSubfolder . 'SiteLoader.php', true, 0755, 0644); $file->write(view('cmf::install.cmf_site_loader', $dataForViews)->render()); // copy configs $subfolder = Folder::load($folder->pwd() . '/Config', true, 0755); $file = File::load($subfolder->pwd() . '/' . $appSubfolder . 'Config.php', true, 0755, 0644); $file->write(view('cmf::install.cmf_config', $dataForViews)->render()); $file = File::load($subfolder->pwd() . '/' . $lowercasedSubfolder . '.routes.php', true, 0755, 0644); $file->write(view('cmf::install.cmf_routes', $dataForViews)->render()); // copy pages controller $subfolder = Folder::load($folder->pwd() . '/Http/Controllers', true, 0755); $file = File::load($subfolder->pwd() . '/PagesController.php', true, 0755, 0644); $file->write(view('cmf::install.pages_controller', $dataForViews)->render()); // create middleware folder File::load($folder->pwd() . '/Http/Middleware/empty', true, 0755, 0644); // make folder in resources File::load(resource_path('/views/' . $lowercasedSubfolder . '/empty'), true, 0755, 0644); if (!$this->input->getOption('no-db-classes')) { // copy base db classes $dbFolder = Folder::load(app_path('/' . $this->input->getArgument('database_classes_app_subfolder')), true, 0755); $file = File::load($dbFolder->pwd() . '/BaseDbModel.php', true, 0755, 0644); $file->write(view('cmf::install.db.base_db_model')->render()); $file = File::load($dbFolder->pwd() . '/BaseDbObject.php', true, 0755, 0644); $file->write(view('cmf::install.db.base_db_object')->render()); // copy admin table classes $subfolder = Folder::load($dbFolder->pwd() . '/Admin', true, 0755); $file = File::load($subfolder->pwd() . '/Admin.php', true, 0755, 0644); $file->write(view('cmf::install.db.admin_object')->render()); $file = File::load($subfolder->pwd() . '/AdminModel.php', true, 0755, 0644); $file->write(view('cmf::install.db.admin_model')->render()); $file = File::load($subfolder->pwd() . '/AdminTableConfig.php', true, 0755, 0644); $file->write(view('cmf::install.db.admin_table_config')->render()); $file = File::load($subfolder->pwd() . '/AdminScaffoldConfig.php', true, 0755, 0644); $file->write(view('cmf::install.db.admin_scaffold_config')->render()); } $this->line('Done'); }
protected function writeMigration($name, $isCreateTable) { $classPath = $this->getFilePath($name); $dataForView = $this->getDataForClassView($name, $isCreateTable); File::save($classPath, view($this->migrationClassView, $dataForView)->render(), 0664); // $this->openFileInPhpStorm($classPath); $this->line("<info>Created Migration:</info> " . pathinfo($classPath, PATHINFO_FILENAME)); $this->line("Migration File: {$classPath}"); $sqlFilePath = $this->getFilePath($name, true); File::save($sqlFilePath, "-- sql\n", 0664); $this->openFileInPhpStorm($sqlFilePath); $this->line("Migration SQL File: {$sqlFilePath}"); if (!$isCreateTable) { $rollbackSqlFilePath = $this->getFilePath($name, true, true); File::save($rollbackSqlFilePath, "-- rollback\n", 0664); $this->openFileInPhpStorm($rollbackSqlFilePath); $this->line("Migration Rollback SQL File: {$rollbackSqlFilePath}"); } $this->openFileInPhpStorm($sqlFilePath); }
public static function configurePublicFilesRoutes() { \Route::get('packages/cmf/{file_path}', function ($filePath) { $filePath = __DIR__ . '/public/' . $filePath; if (File::exist($filePath)) { return response(File::contents(), 200, ['Content-Type' => File::load()->mime()]); } else { return response('File not found'); } })->where(['file_path' => '(js|css|img)\\/.+\\.[a-z0-9]+$']); }
protected function createScaffoldConfig($dataForViews) { $scaffoldConfigFile = $dataForViews['files']['scaffold_config']; if (File::exist($scaffoldConfigFile)) { File::remove(); } File::save($scaffoldConfigFile, view($this->scaffoldConfigView, $dataForViews)->render(), 0664); $this->openFileInPhpStorm($scaffoldConfigFile); $this->line("ScaffoldConfig class created ({$scaffoldConfigFile})"); }