File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -61,11 +61,15 @@ private function fillTemplate($templateData)
61
61
$ templateData = $ this ->fillSoftDeletes ($ templateData );
62
62
63
63
$ fillables = [];
64
+ $ primaryKey = 'id ' ;
64
65
65
66
foreach ($ this ->commandData ->fields as $ field ) {
66
67
if ($ field ->isFillable ) {
67
68
$ fillables [] = "' " .$ field ->name ."' " ;
68
69
}
70
+ if ($ field ->isPrimary ) {
71
+ $ primaryKey = $ field ->name ;
72
+ }
69
73
}
70
74
71
75
$ templateData = $ this ->fillDocs ($ templateData );
@@ -76,6 +80,9 @@ private function fillTemplate($templateData)
76
80
$ primary = infy_tab ()."protected \$primaryKey = ' " .$ this ->commandData ->getOption ('primary ' )."'; \n" ;
77
81
} else {
78
82
$ primary = '' ;
83
+ if ($ this ->commandData ->getOption ('fieldsFile ' ) && $ primaryKey != 'id ' ) {
84
+ $ primary = infy_tab ()."protected \$primaryKey = ' " .$ primaryKey ."'; \n" ;
85
+ }
79
86
}
80
87
81
88
$ templateData = str_replace ('$PRIMARY$ ' , $ primary , $ templateData );
You can’t perform that action at this time.
0 commit comments