2
2
3
3
namespace InfyOm \Generator \Common ;
4
4
5
- use Doctrine \DBAL \Schema \Column ;
6
5
use Illuminate \Support \Str ;
7
6
8
7
class GeneratorField
@@ -40,15 +39,16 @@ public function parseDBType($dbInput)
40
39
if (!Str::contains ($ dbInput , ': ' )) {
41
40
$ this ->dbType = $ dbInput ;
42
41
$ this ->prepareMigrationText ();
42
+
43
43
return ;
44
44
}
45
45
46
46
$ dbInputArr = explode (': ' , $ dbInput );
47
- $ dbType = (string )array_shift ($ dbInputArr );
47
+ $ dbType = (string ) array_shift ($ dbInputArr );
48
48
49
49
if (Str::contains ($ dbType , ', ' )) {
50
50
$ dbTypeArr = explode (', ' , $ dbType );
51
- $ this ->dbType = (string )array_shift ($ dbTypeArr );
51
+ $ this ->dbType = (string ) array_shift ($ dbTypeArr );
52
52
$ this ->dbTypeParams = $ dbTypeArr ;
53
53
} else {
54
54
$ this ->dbType = $ dbType ;
@@ -68,16 +68,18 @@ public function parseHtmlInput($htmlInput)
68
68
{
69
69
if (empty ($ htmlInput )) {
70
70
$ this ->htmlType = 'text ' ;
71
+
71
72
return ;
72
73
}
73
74
74
75
if (!Str::contains ($ htmlInput , ': ' )) {
75
76
$ this ->htmlType = $ htmlInput ;
77
+
76
78
return ;
77
79
}
78
80
79
81
$ htmlInputArr = explode (': ' , $ htmlInput );
80
- $ this ->htmlType = (string )array_shift ($ htmlInputArr );
82
+ $ this ->htmlType = (string ) array_shift ($ htmlInputArr );
81
83
$ this ->htmlValues = explode (', ' , implode (': ' , $ htmlInputArr ));
82
84
}
83
85
@@ -114,10 +116,11 @@ public function parseOptions($options)
114
116
private function prepareMigrationText ()
115
117
{
116
118
$ this ->migrationText = '$table-> ' ;
117
- $ this ->migrationText .= $ this ->dbType . "(' " . $ this ->name . "' " ;
119
+ $ this ->migrationText .= $ this ->dbType . "(' " . $ this ->name . "' " ;
118
120
119
121
if (!count ($ this ->dbTypeParams ) and !count ($ this ->dbExtraFunctions )) {
120
- $ this ->migrationText .= "); " ;
122
+ $ this ->migrationText .= '); ' ;
123
+
121
124
return ;
122
125
}
123
126
@@ -131,25 +134,26 @@ private function prepareMigrationText()
131
134
// $this->migrationText .= ']';
132
135
// }
133
136
foreach ($ this ->dbTypeParams as $ dbTypeParam ) {
134
- $ this ->migrationText .= ', ' . $ dbTypeParam ;
137
+ $ this ->migrationText .= ', ' . $ dbTypeParam ;
135
138
}
136
139
}
137
140
138
- $ this ->migrationText .= " ) " ;
141
+ $ this ->migrationText .= ' ) ' ;
139
142
140
143
if (!count ($ this ->dbExtraFunctions )) {
141
- $ this ->migrationText .= "; " ;
144
+ $ this ->migrationText .= '; ' ;
145
+
142
146
return ;
143
147
}
144
148
145
149
$ this ->foreignKeyText = '' ;
146
150
foreach ($ this ->dbExtraFunctions as $ dbExtraFunction ) {
147
151
$ dbExtraFunctionArr = explode (', ' , $ dbExtraFunction );
148
- $ functionName = (string )array_shift ($ dbExtraFunctionArr );
152
+ $ functionName = (string ) array_shift ($ dbExtraFunctionArr );
149
153
if ($ functionName === 'foreign ' ) {
150
154
$ foreignTable = array_shift ($ dbExtraFunctionArr );
151
155
$ foreignField = array_shift ($ dbExtraFunctionArr );
152
- $ this ->foreignKeyText .= "\$table->foreign(' " . $ this ->name . "')->references(' " . $ foreignField . "')->on(' " . $ foreignTable . "') " ;
156
+ $ this ->foreignKeyText .= "\$table->foreign(' " . $ this ->name . "')->references(' " . $ foreignField. "')->on(' " . $ foreignTable. "') " ;
153
157
if (count ($ dbExtraFunctionArr )) {
154
158
$ cascade = array_shift ($ dbExtraFunctionArr );
155
159
if ($ cascade === 'cascade ' ) {
@@ -158,7 +162,7 @@ private function prepareMigrationText()
158
162
}
159
163
$ this ->foreignKeyText .= '; ' ;
160
164
} else {
161
- $ this ->migrationText .= '-> ' . $ functionName ;
165
+ $ this ->migrationText .= '-> ' . $ functionName ;
162
166
$ this ->migrationText .= '( ' ;
163
167
$ this ->migrationText .= implode (', ' , $ dbExtraFunctionArr );
164
168
$ this ->migrationText .= ') ' ;
@@ -234,7 +238,7 @@ public function getTitle()
234
238
public function variables ()
235
239
{
236
240
return [
237
- 'fieldName ' => $ this ->name ,
241
+ 'fieldName ' => $ this ->name ,
238
242
'fieldTitle ' => $ this ->getTitle (),
239
243
];
240
244
}
0 commit comments