Skip to content

Commit d0cebf8

Browse files
authored
Remove Laravel 7 or newer checks. (#504)
1 parent 9c32489 commit d0cebf8

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/Generators/MigrationGenerator.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected function buildDefinition(Model $model)
165165
}
166166

167167
$column_definition = self::INDENT;
168-
if ($dataType === 'bigIncrements' && $this->isLaravel7orNewer()) {
168+
if ($dataType === 'bigIncrements') {
169169
$column_definition .= '$table->id(';
170170
} elseif ($dataType === 'rememberToken') {
171171
$column_definition .= '$table->rememberToken(';
@@ -198,7 +198,7 @@ protected function buildDefinition(Model $model)
198198
$column->modifiers()
199199
);
200200

201-
if ($column->dataType() === 'id' && $this->isLaravel7orNewer()) {
201+
if ($column->dataType() === 'id') {
202202
$column_definition = $foreign;
203203
$foreign = '';
204204
}
@@ -210,7 +210,7 @@ function ($modifier) use ($column) {
210210
|| (is_array($modifier) && key($modifier) === 'onDelete')
211211
|| (is_array($modifier) && key($modifier) === 'onUpdate')
212212
|| $modifier === 'foreign'
213-
|| ($modifier === 'nullable' && $this->isLaravel7orNewer() && $column->dataType() === 'id');
213+
|| ($modifier === 'nullable' && $column->dataType() === 'id');
214214
}
215215
);
216216
}
@@ -277,14 +277,10 @@ protected function buildPivotTableDefinition(array $segments)
277277
$on = Str::plural($column);
278278
$foreign = Str::singular($column) . '_' . $references;
279279

280-
if (! $this->isLaravel7orNewer()) {
281-
$definition .= self::INDENT . '$table->unsignedBigInteger(\'' . $foreign . '\');' . PHP_EOL;
282-
}
283-
284280
if (config('blueprint.use_constraints')) {
285281
$this->hasForeignKeyConstraints = true;
286282
$definition .= $this->buildForeignKey($foreign, $on, 'id') . ';' . PHP_EOL;
287-
} elseif ($this->isLaravel7orNewer()) {
283+
} else {
288284
$definition .= self::INDENT . '$table->foreignId(\'' . $foreign . '\');' . PHP_EOL;
289285
}
290286
}
@@ -322,7 +318,7 @@ protected function buildForeignKey(string $column_name, ?string $on, string $typ
322318
$on_update_suffix = self::ON_UPDATE_CLAUSES[$on_update_clause];
323319
}
324320

325-
if ($this->isLaravel7orNewer() && $type === 'id') {
321+
if ($type === 'id') {
326322
$prefix = in_array('nullable', $modifiers)
327323
? '$table->foreignId' . "('{$column_name}')->nullable()"
328324
: '$table->foreignId' . "('{$column_name}')";
@@ -401,11 +397,6 @@ function (SplFileInfo $file) {
401397
return $dir . $timestamp->format('Y_m_d_His') . $name;
402398
}
403399

404-
protected function isLaravel7orNewer()
405-
{
406-
return version_compare(App::version(), '7.0.0', '>=');
407-
}
408-
409400
protected function getPivotClassName(array $segments)
410401
{
411402
return 'Create' . Str::studly($this->getPivotTableName($segments)) . 'Table';

0 commit comments

Comments
 (0)