Skip to content

Commit 04b62e1

Browse files
eafarooqiDEEHFAR1
and
DEEHFAR1
authored
Support for models with different database connection property (#1799)
* Enhancement: Support for models with different database connection property * Enhancement: Support for models with different database connection property --------- Co-authored-by: DEEHFAR1 <[email protected]>
1 parent fa2c392 commit 04b62e1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/DataSource/Builder.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,15 @@ private function filterNestedRelation(string $table, array $columns, string $sea
253253

254254
private function getColumnList(string $modelTable): array
255255
{
256+
$connection = $this->query instanceof EloquentBuilder
257+
? $this->query->getModel()->getConnection()->getName()
258+
/** @phpstan-ignore-next-line */
259+
: $this->query->getConnection()->getConfig('name');
260+
256261
try {
257262
return PowerGridTableCache::getOrCreate(
258263
$modelTable,
259-
fn () => collect(Schema::getColumns($modelTable))
264+
fn () => collect(Schema::connection($connection)->getColumns($modelTable))
260265
->pluck('type', 'name')
261266
->toArray()
262267
);
@@ -266,7 +271,7 @@ private function getColumnList(string $modelTable): array
266271
'throwable' => $throwable->getTrace(),
267272
]);
268273

269-
return Schema::getColumnListing($modelTable);
274+
return Schema::connection($connection)->getColumnListing($modelTable);
270275
}
271276
}
272277

0 commit comments

Comments
 (0)