Skip to content

Commit b4c6000

Browse files
authored
Fixes pivot table filename and column references (#139)
1 parent f5e594e commit b4c6000

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Generators/MigrationGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ protected function buildDefinition(Model $model)
163163
return trim($definition);
164164
}
165165

166-
protected function buildPivotTableDefinition(array $segments, $dataType = 'bigIncrements')
166+
protected function buildPivotTableDefinition(array $segments, $dataType = 'unsignedBigInteger')
167167
{
168168
$definition = '';
169169

170170
foreach ($segments as $segment) {
171-
$column = $segment . '_id';
171+
$column = strtolower($segment) . '_id';
172172
$definition .= self::INDENT . '$table->' . $dataType . "('{$column}');" . PHP_EOL;
173173
}
174174

@@ -197,7 +197,7 @@ protected function isLaravel7orNewer()
197197

198198
protected function getPivotClassName(array $segments)
199199
{
200-
return 'Create' . Str::studly($this->getPivotTableName($segments)) . 'PivotTable';
200+
return 'Create' . Str::studly($this->getPivotTableName($segments)) . 'Table';
201201
}
202202

203203
protected function getPivotTableName(array $segments)

0 commit comments

Comments
 (0)