Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MfN-Berlin
gdm
Commits
3983db68
Commit
3983db68
authored
Nov 27, 2019
by
Ortiz-Troncoso, Alvaro
Browse files
Do not change names of tables (e.g. Species becomes Specie ???)
parent
0c37f1f6
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/tools/MakeModelsCommand.php
View file @
3983db68
...
...
@@ -4,7 +4,7 @@ namespace Iber\Generator\Commands;
use
Illuminate\Database\Connection
;
use
Illuminate\Database\Events\StatementPrepared
;
use
Illuminate\Support\Pluralizer
;
//
use Illuminate\Support\Pluralizer;
use
Illuminate\Console\GeneratorCommand
;
use
Iber\Generator\Utilities\RuleProcessor
;
use
Iber\Generator\Utilities\SetGetGenerator
;
...
...
@@ -188,12 +188,19 @@ class MakeModelsCommand extends GeneratorCommand {
$class
=
VariableConversion
::
convertTableNameToClassName
(
$prefixRemovedTableName
);
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
if (method_exists($this, 'qualifyClass')) {
$name = Pluralizer::singular($this->qualifyClass($prefix . $class));
} else {
$name = Pluralizer::singular($this->parseName($prefix . $class));
}
*/
if
(
method_exists
(
$this
,
'qualifyClass'
))
{
$name
=
$this
->
qualifyClass
(
$prefix
.
$class
);
}
else
{
$name
=
$this
->
parseName
(
$prefix
.
$class
);
}
$path
=
$this
->
getPath
(
$name
);
$this
->
info
(
basename
(
$path
)
.
":
\t
is data table: created. "
);
...
...
@@ -307,10 +314,14 @@ class MakeModelsCommand extends GeneratorCommand {
// Hence we use the following naming convention:
//tableName_columnName where columnName contains the foreign key instead of the target table's name as function name.
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$referenced_model = ucfirst(Pluralizer::singular($relation['referenced_table']));
//
$referenced_table_trunc = Pluralizer::singular($relation['referenced_table']) . "_" . explode("_",$foreign_key)[0];
$referenced_table_trunc = Pluralizer::singular($relation['referenced_table']) . "_" . explode("_",$foreign_key)[0];
$referenced_table_trunc = Pluralizer::singular($relation['referenced_table']) . "_" . strtolower(explode("_", $foreign_key)[0]);
*/
$referenced_model
=
ucfirst
(
$relation
[
'referenced_table'
]);
$referenced_table_trunc
=
$relation
[
'referenced_table'
]
.
"_"
.
strtolower
(
explode
(
"_"
,
$foreign_key
)[
0
]);
$stub
=
<<<RELATION
/**
...
...
lib/tools/add_controller.php
View file @
3983db68
...
...
@@ -734,10 +734,16 @@ if (substr($name, 0, 3) != "Gdm") {
// $content = str_replace('GDM_NAME', GDM_NAME, $content);
$content
=
str_replace
(
'/GDM_DATAMODEL_VERSION/'
,
'/'
.
GDM_DATAMODEL_VERSION
.
'/'
,
$content
);
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('SINGULAR_NAME', singularize($name), $content);
*/
$content
=
str_replace
(
'SINGULAR_NAME'
,
$name
,
$content
);
$content
=
str_replace
(
'ROUTE_NAME'
,
toCamelCase
(
$name
),
$content
);
$content
=
str_replace
(
'CAP_NAME'
,
ucfirst
(
$name
),
$content
);
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('MODEL_NAME', ucfirst(singularize($name)), $content);
*/
$content
=
str_replace
(
'MODEL_NAME'
,
ucfirst
(
$name
),
$content
);
$content
=
str_replace
(
'DB_TABLE_NAME'
,
$table_name
,
$content
);
$content
=
str_replace
(
'THIS_TABLE_NAME'
,
$name
,
$content
);
$content
=
str_replace
(
'COLUMNS'
,
$cols
,
$content
);
...
...
@@ -787,15 +793,21 @@ PHPCODE;
$relation_content
=
str_replace
(
'THIS_REQUEST'
,
$_SERVER
[
'PHP_SELF'
],
$relation_content
);
// @todo !! to CamelCase
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$relation_content = str_replace('REFERENCED_MODEL', ucfirst(singularize($referenced_table)), $relation_content);
$relation_content = str_replace('REFERENCED_TABLE_SINGULAR_NAME', singularize($referenced_table), $relation_content);
*/
$relation_content
=
str_replace
(
'REFERENCED_MODEL'
,
ucfirst
(
$referenced_table
),
$relation_content
);
$relation_content
=
str_replace
(
'REFERENCED_TABLE_SINGULAR_NAME'
,
$referenced_table
,
$relation_content
);
$relation_content
=
str_replace
(
'REFERENCED_TABLE_NAME'
,
toCamelCase
(
$referenced_table
),
$relation_content
);
$relation_content
=
str_replace
(
'THIS_TABLE_NAME'
,
toCamelCase
(
$table_name
),
$relation_content
);
$relations
.
=
"
\n\t
"
.
$relation_content
;
$relation_content2
=
$relation_stub2
;
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$relation_content2 = str_replace('REFERENCED_TABLE_SINGULAR_NAME', singularize($referenced_table), $relation_content2);
*/
$relation_content2
=
str_replace
(
'REFERENCED_TABLE_SINGULAR_NAME'
,
$referenced_table
,
$relation_content2
);
$relations2
.
=
"
\n\t
"
.
$relation_content2
;
}
$related_tables
=
str_replace
(
" "
,
", "
,
trim
(
$related_tables
));
...
...
lib/tools/add_form.php
View file @
3983db68
...
...
@@ -128,7 +128,10 @@ COMMAND;
foreach
(
$foreignKeys
as
$fk
)
{
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$modelName = ucfirst(singularize(explode("_", $fk['foreign_key'])[0]));
*/
$modelName
=
ucfirst
(
explode
(
"_"
,
$fk
[
'foreign_key'
])[
0
]);
$modelTableName
=
$fk
[
'referenced_table'
];
if
(
$modelName
==
"User"
)
{
...
...
lib/tools/add_views.php
View file @
3983db68
...
...
@@ -218,7 +218,10 @@ if (substr($name, 0, 3) != "Gdm") {
PHPCODE;
$content
=
str_replace
(
'CNAME'
,
ucfirst
(
$name
),
$content
);
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('MODEL_NAME', singularize(ucfirst($name)), $content);
*/
$content
=
str_replace
(
'MODEL_NAME'
,
ucfirst
(
$name
),
$content
);
$content
=
str_replace
(
'NAME'
,
$name
,
$content
);
$content
=
str_replace
(
'COLUMNS'
,
$cols
,
$content
);
$content
=
str_replace
(
'GDM_PAGE_LENGTH'
,
GDM_PAGE_LENGTH
,
$content
);
...
...
@@ -421,7 +424,10 @@ PHPCODE;
PHPCODE;
$content
=
str_replace
(
'CNAME'
,
ucfirst
(
$name
),
$content
);
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('MODEL_NAME', singularize(ucfirst($name)), $content);
*/
$content
=
str_replace
(
'MODEL_NAME'
,
ucfirst
(
$name
),
$content
);
$content
=
str_replace
(
'NAME'
,
$name
,
$content
);
$content
=
str_replace
(
'COLUMNS'
,
$cols
,
$content
);
$content
=
str_replace
(
'GDM_PAGE_LENGTH'
,
GDM_PAGE_LENGTH
,
$content
);
...
...
@@ -527,7 +533,10 @@ PHPCODE;
PHP_CODE;
$content
=
str_replace
(
'CNAME'
,
ucfirst
(
$name
),
$content
);
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('MODEL_NAME', singularize(ucfirst($name)), $content);
*/
$content
=
str_replace
(
'MODEL_NAME'
,
ucfirst
(
$name
),
$content
);
$content
=
str_replace
(
'NAME'
,
$name
,
$content
);
@
mkdir
(
"../../resources/views/data/"
.
$name
);
...
...
@@ -639,7 +648,10 @@ PHPCODE;
$content
=
str_replace
(
'CNAME'
,
ucfirst
(
$name
),
$content
);
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('MODEL_NAME', singularize(ucfirst($name)), $content);
*/
$content
=
str_replace
(
'MODEL_NAME'
,
ucfirst
(
$name
),
$content
);
$content
=
str_replace
(
'NAME'
,
$name
,
$content
);
@
mkdir
(
"../../resources/views/data/"
.
$name
);
...
...
@@ -670,7 +682,10 @@ PHPCODE;
@endsection
PHPCODE;
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('MODEL_NAME', singularize(ucfirst($name)), $content);
*/
$content
=
str_replace
(
'MODEL_NAME'
,
ucfirst
(
$name
),
$content
);
$content
=
str_replace
(
'NAME'
,
$name
,
$content
);
@
mkdir
(
"../../resources/views/data/"
.
$name
);
...
...
@@ -706,7 +721,10 @@ PHPCODE;
@endsection
PHPCODE;
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('MODEL_NAME', singularize(ucfirst($name)), $content);
*/
$content
=
str_replace
(
'MODEL_NAME'
,
ucfirst
(
$name
),
$content
);
$content
=
str_replace
(
'NAME'
,
$name
,
$content
);
@
mkdir
(
"../../resources/views/data/"
.
$name
);
...
...
@@ -762,7 +780,10 @@ PHPCODE;
PHPCODE;
/* Do not change names of tables (e.g. "Species" becomes "Specie" ???)
$content = str_replace('MODEL_NAME', singularize(ucfirst($name)), $content);
*/
$content
=
str_replace
(
'MODEL_NAME'
,
ucfirst
(
$name
),
$content
);
@
mkdir
(
"../../resources/views/data/"
.
$name
);
file_put_contents
(
"../../resources/views/data/"
.
$name
.
"/edit.blade.php"
,
$content
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment