Convert an underscored table name to an uppercased class name.
public static convertTableNameToClassName ( $table ) : mixed | ||
$table | ||
return | mixed |
/** * Generate a model file from a database table. * * @param $table */ protected function generateTable($table) { //prefix is the sub-directory within app $prefix = $this->option('dir'); $class = VariableConversion::convertTableNameToClassName($table); $name = rtrim($this->parseName($prefix . $class), 's'); if ($this->files->exists($path = $this->getPath($name))) { return $this->error($this->extends . ' for ' . $table . ' already exists!'); } $this->makeDirectory($path); $this->files->put($path, $this->replaceTokens($name, $table)); $this->info($this->extends . ' for ' . $table . ' created successfully.'); }
/** * Generate a model file from a database table. * * @param $table * @return void */ protected function generateTable($table) { //prefix is the sub-directory within app $prefix = $this->option('dir'); $ignoreTable = $this->option("ignore"); if ($this->option("ignoresystem")) { $ignoreSystem = "users,permissions,permission_role,roles,role_user,users,migrations,password_resets,api_keys,api_logs,failed_jobs,jobs,phinx_mig,sessions"; if (is_string($ignoreTable)) { $ignoreTable .= "," . $ignoreSystem; } else { $ignoreTable = $ignoreSystem; } } // if we have ignore tables, we need to find all the posibilites if (is_string($ignoreTable) && preg_match("/^" . $table . "|^" . $table . ",|," . $table . ",|," . $table . "\$/", $ignoreTable)) { $this->info($table . " is ignored"); return; } $class = VariableConversion::convertTableNameToClassName($table); $name = rtrim($this->parseName($prefix . $class), 's'); if ($this->files->exists($path = $this->getPath($name)) && !$this->option('force')) { return $this->error($this->extends . ' for ' . $table . ' already exists!'); } $this->makeDirectory($path); $this->files->put($path, $this->replaceTokens($name, $table)); $this->info($this->extends . ' for ' . $table . ' created successfully.'); }