5
5
use Blueprint \Contracts \Generator ;
6
6
use Blueprint \Models \Model ;
7
7
use Carbon \Carbon ;
8
+ use Illuminate \Support \Facades \App ;
8
9
use Illuminate \Support \Str ;
9
10
10
11
class MigrationGenerator implements Generator
@@ -62,7 +63,7 @@ protected function buildDefinition(Model $model)
62
63
$ dataType = 'uuid ' ;
63
64
}
64
65
65
- if ($ this -> isLaravel7orNewer () && $ dataType === 'bigIncrements ' ) {
66
+ if ($ dataType === 'bigIncrements ' && $ this -> isLaravel7orNewer () ) {
66
67
$ definition .= self ::INDENT . '$table->id( ' ;
67
68
} else {
68
69
$ definition .= self ::INDENT . '$table-> ' . $ dataType . "(' {$ column ->name ()}' " ;
@@ -83,13 +84,7 @@ protected function buildDefinition(Model $model)
83
84
foreach ($ column ->modifiers () as $ modifier ) {
84
85
if (is_array ($ modifier )) {
85
86
if (key ($ modifier ) === 'foreign ' ) {
86
- $ foreign =
87
- self ::INDENT .
88
- '$table->foreign( ' .
89
- "' {$ column ->name ()}')->references('id')->on(' " .
90
- Str::lower (Str::plural (current ($ modifier ))) .
91
- "')->onDelete('cascade'); " .
92
- PHP_EOL ;
87
+ $ foreign = self ::INDENT . '$table->foreign( ' . "' {$ column ->name ()}')->references('id')->on(' " . Str::lower (Str::plural (current ($ modifier ))) . "')->onDelete('cascade'); " . PHP_EOL ;
93
88
} else {
94
89
$ definition .= '-> ' . key ($ modifier ) . '( ' . current ($ modifier ) . ') ' ;
95
90
}
@@ -124,6 +119,6 @@ protected function getPath(Model $model, Carbon $timestamp)
124
119
125
120
protected function isLaravel7orNewer ()
126
121
{
127
- return version_compare (app ()-> version (), '7.0.0 ' , '>= ' );
122
+ return version_compare (App:: version (), '7.0.0 ' , '>= ' );
128
123
}
129
124
}
0 commit comments