Skip to content

Commit f5f3a04

Browse files
committed
feat: expose create columns from headers helper method
1 parent 31652f6 commit f5f3a04

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/SQLLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function into(
7070
array $formatOptions = [],
7171
?string $when = null,
7272
): static {
73-
if (empty($columns)) {
74-
$columns = $this->buildDefaultColumns($table, $columns);
73+
if (! $columns && $this->defaultColumns) {
74+
$columns = $this->createColumnsFromHeaders($table, $this->defaultColumns);
7575
}
7676

7777
if (! $formatOptions) {
@@ -90,9 +90,9 @@ public function into(
9090
return $this;
9191
}
9292

93-
protected function buildDefaultColumns(string $table, array $columns): array
93+
public function createColumnsFromHeaders(string $table, array $columns): array
9494
{
95-
$columns = array_map('strtolower', $this->defaultColumns);
95+
$columns = array_map('strtolower', $columns);
9696
$schemaColumns = collect(Schema::connection(config('sql-loader.connection'))->getColumns($table));
9797

9898
$dates = $schemaColumns->filter(fn ($column) => in_array($column['type'], [

0 commit comments

Comments
 (0)