Skip to content

Commit

Permalink
Enhancement: Support for models with different database connection pr…
Browse files Browse the repository at this point in the history
…operty
  • Loading branch information
DEEHFAR1 committed Dec 9, 2024
1 parent c30c4fc commit adee8b6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/DataSource/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,14 @@ private function filterNestedRelation(string $table, array $columns, string $sea

private function getColumnList(string $modelTable): array
{
$connection = $this->query instanceof EloquentBuilder
? $this->query->getModel()->getConnection()->getName()
: $this->query->getConnection()->getName();

Check failure on line 258 in src/DataSource/Builder.php

View workflow job for this annotation

GitHub Actions / PHP:8.3 / L:11.*

Call to an undefined method Illuminate\Database\ConnectionInterface::getName().

try {
return PowerGridTableCache::getOrCreate(
$modelTable,
fn () => collect(Schema::getColumns($modelTable))
fn () => collect(Schema::connection($connection)->getColumns($modelTable))
->pluck('type', 'name')
->toArray()
);
Expand All @@ -266,7 +270,7 @@ private function getColumnList(string $modelTable): array
'throwable' => $throwable->getTrace(),
]);

return Schema::getColumnListing($modelTable);
return Schema::connection($connection)->getColumnListing($modelTable);
}
}

Expand Down

0 comments on commit adee8b6

Please sign in to comment.