Skip to content

Commit

Permalink
Support for models with different database connection property (#1799)
Browse files Browse the repository at this point in the history
* Enhancement: Support for models with different database connection property

* Enhancement: Support for models with different database connection property

---------

Co-authored-by: DEEHFAR1 <[email protected]>
  • Loading branch information
eafarooqi and DEEHFAR1 authored Dec 12, 2024
1 parent fa2c392 commit 04b62e1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/DataSource/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,15 @@ 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()
/** @phpstan-ignore-next-line */
: $this->query->getConnection()->getConfig('name');

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 +271,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 04b62e1

Please sign in to comment.