@@ -65,26 +65,6 @@ function get_template_file_path(string $templateName, string $templateType): str
65
65
return $ path ;
66
66
}
67
67
68
- return get_templates_package_path ($ templateType ).'/templates/ ' .$ templateName .'.blade.php ' ;
69
- }
70
- }
71
-
72
- if (!function_exists ('get_file_path ' )) {
73
- function get_file_path (string $ templateName , string $ templateType ): string
74
- {
75
- $ templateName = str_replace ('. ' , '/ ' , $ templateName );
76
-
77
- $ templatesPath = config (
78
- 'laravel_generator.path.templates_dir ' ,
79
- resource_path ('infyom/infyom-generator-templates/ ' )
80
- );
81
-
82
- $ path = $ templatesPath .$ templateName .'.blade.php ' ;
83
-
84
- if (file_exists ($ path )) {
85
- return $ path ;
86
- }
87
-
88
68
return get_templates_package_path ($ templateType ).'/ ' .$ templateName .'.blade.php ' ;
89
69
}
90
70
}
@@ -100,89 +80,29 @@ function get_templates_package_path(string $templateType): string
100
80
}
101
81
}
102
82
103
- if (!function_exists ('get_template ' )) {
104
- function get_template (string $ templateName , string $ templateType ): string
105
- {
106
- $ path = get_template_file_path ($ templateName , $ templateType );
107
-
108
- return g_filesystem ()->getFile ($ path );
109
- }
110
- }
111
-
112
- if (!function_exists ('fill_template ' )) {
113
- function fill_template (array $ variables , string $ template ): string
114
- {
115
- foreach ($ variables as $ variable => $ value ) {
116
- $ template = str_replace ($ variable , $ value , $ template );
117
- }
118
-
119
- return $ template ;
120
- }
121
- }
122
-
123
- if (!function_exists ('fill_field_template ' )) {
124
- function fill_field_template (array $ variables , string $ template , GeneratorField $ field ): string
125
- {
126
- foreach ($ variables as $ variable => $ key ) {
127
- $ template = str_replace ($ variable , $ field ->$ key , $ template );
128
- }
129
-
130
- return $ template ;
131
- }
132
- }
133
-
134
- if (!function_exists ('fill_template_with_field_data ' )) {
135
- function fill_template_with_field_data (array $ variables , array $ fieldVariables , string $ template , GeneratorField $ field ): string
83
+ if (!function_exists ('model_name_from_table_name ' )) {
84
+ function model_name_from_table_name (string $ tableName ): string
136
85
{
137
- $ template = fill_template ($ variables , $ template );
138
-
139
- return fill_field_template ($ fieldVariables , $ template , $ field );
86
+ return Str::ucfirst (Str::camel (Str::singular ($ tableName )));
140
87
}
141
88
}
142
89
143
- if (!function_exists ('fill_template_with_field_data_locale ' )) {
144
- function fill_template_with_field_data_locale ( array $ variables , array $ fieldVariables , string $ template , GeneratorField $ field ): string
90
+ if (!function_exists ('create_resource_route_names ' )) {
91
+ function create_resource_route_names ( $ name , $ isScaffold = false ): array
145
92
{
146
- $ template = fill_template ($ variables , $ template );
147
- $ modelName = $ variables ['$MODEL_NAME_PLURAL_CAMEL$ ' ];
148
-
149
- return fill_field_template_locale ($ fieldVariables , $ template , $ field , $ modelName );
150
- }
151
- }
93
+ $ result = [
94
+ "'index' => ' $ name.index' " ,
95
+ "'store' => ' $ name.store' " ,
96
+ "'show' => ' $ name.show' " ,
97
+ "'update' => ' $ name.update' " ,
98
+ "'destroy' => ' $ name.destroy' " ,
99
+ ];
152
100
153
- if (!function_exists ('fill_field_template_locale ' )) {
154
- function fill_field_template_locale (array $ variables , string $ template , GeneratorField $ field , string $ modelName ): string
155
- {
156
- foreach ($ variables as $ variable => $ key ) {
157
- $ value = $ field ->name ;
158
- $ template = str_replace ($ variable , "@lang('models/ $ modelName.fields. $ value') " , $ template );
101
+ if ($ isScaffold ) {
102
+ $ result [] = "'create' => ' $ name.create' " ;
103
+ $ result [] = "'edit' => ' $ name.edit' " ;
159
104
}
160
105
161
- return $ template ;
106
+ return $ result ;
162
107
}
163
108
}
164
-
165
- if (!function_exists ('model_name_from_table_name ' )) {
166
- function model_name_from_table_name (string $ tableName ): string
167
- {
168
- return Str::ucfirst (Str::camel (Str::singular ($ tableName )));
169
- }
170
- }
171
-
172
- function createResourceRouteNames ($ name , $ isScaffold = false )
173
- {
174
- $ result = [
175
- "'index' => ' $ name.index' " ,
176
- "'store' => ' $ name.store' " ,
177
- "'show' => ' $ name.show' " ,
178
- "'update' => ' $ name.update' " ,
179
- "'destroy' => ' $ name.destroy' " ,
180
- ];
181
-
182
- if ($ isScaffold ) {
183
- $ result [] = "'create' => ' $ name.create' " ;
184
- $ result [] = "'edit' => ' $ name.edit' " ;
185
- }
186
-
187
- return $ result ;
188
- }
0 commit comments