From 8fb738eb9d2d97bff3b2817b64b4e28b5ab2164c Mon Sep 17 00:00:00 2001 From: eele94 Date: Thu, 9 Jan 2025 03:05:42 +0100 Subject: [PATCH 1/2] fix: remove unnecessary facade call and make summarizers compatible with Sushi --- packages/tables/src/Columns/Summarizers/Summarizer.php | 7 +++---- packages/tables/src/Concerns/CanSummarizeRecords.php | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/tables/src/Columns/Summarizers/Summarizer.php b/packages/tables/src/Columns/Summarizers/Summarizer.php index 7862d19c0c6..7c856aa74de 100644 --- a/packages/tables/src/Columns/Summarizers/Summarizer.php +++ b/packages/tables/src/Columns/Summarizers/Summarizer.php @@ -7,7 +7,6 @@ use Filament\Support\Concerns\HasExtraAttributes; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Query\Builder; -use Illuminate\Support\Facades\DB; class Summarizer extends ViewComponent { @@ -112,7 +111,7 @@ function (EloquentBuilder $relatedQuery) use ($baseQuery, $query): EloquentBuild ->prepend('pivot_'); $isPivotAttributeSelected = collect($query->getQuery()->getColumns()) - ->contains(fn (string $column): bool => str($column)->endsWith(" as {$pivotAttribute}")); + ->contains(fn(string $column): bool => str($column)->endsWith(" as {$pivotAttribute}")); $attribute = $isPivotAttributeSelected ? $pivotAttribute : $attribute; @@ -120,14 +119,14 @@ function (EloquentBuilder $relatedQuery) use ($baseQuery, $query): EloquentBuild if ($isPivotAttributeSelected) { $query->getQuery()->columns = array_filter( $query->getQuery()->columns, - fn (mixed $column): bool => $column !== "{$query->getQuery()->joins[0]->table}.*", + fn(mixed $column): bool => $column !== "{$query->getQuery()->joins[0]->table}.*", ); } } $asName = (string) str($query->getModel()->getTable())->afterLast('.'); - $query = DB::connection($query->getModel()->getConnectionName()) + $query = $query->getModel()->resolveConnection() ->table($query->toBase(), $asName); if ($this->hasQueryModification()) { diff --git a/packages/tables/src/Concerns/CanSummarizeRecords.php b/packages/tables/src/Concerns/CanSummarizeRecords.php index a0a096c4bdb..99d78acd706 100644 --- a/packages/tables/src/Concerns/CanSummarizeRecords.php +++ b/packages/tables/src/Concerns/CanSummarizeRecords.php @@ -7,7 +7,6 @@ use Illuminate\Database\Connection; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Query\Expression; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use stdClass; @@ -71,7 +70,7 @@ public function getTableSummarySelectedState(Builder $query, ?Closure $modifyQue $queryToJoin = $query->clone(); $joins = []; - $query = DB::connection($query->getModel()->getConnectionName()) + $query = $query->getModel()->resolveConnection() ->table($query->toBase(), $query->getModel()->getTable()); if ($modifyQueryUsing) { From cde427e820fe3f22f67457eaa061a4df2eb51999 Mon Sep 17 00:00:00 2001 From: eele94 Date: Thu, 9 Jan 2025 03:35:03 +0100 Subject: [PATCH 2/2] clean: style, composer cs --- .../support/resources/views/components/tabs/item.blade.php | 2 +- packages/tables/src/Columns/Summarizers/Summarizer.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/support/resources/views/components/tabs/item.blade.php b/packages/support/resources/views/components/tabs/item.blade.php index 3a3e933d40d..9e4ddd6507a 100644 --- a/packages/support/resources/views/components/tabs/item.blade.php +++ b/packages/support/resources/views/components/tabs/item.blade.php @@ -62,7 +62,7 @@ 'role' => 'tab', ]) ->class([ - 'fi-tabs-item group flex items-center justify-center gap-x-2 rounded-lg px-3 py-2 text-sm font-medium outline-none whitespace-nowrap transition duration-75', + 'fi-tabs-item group flex items-center justify-center gap-x-2 whitespace-nowrap rounded-lg px-3 py-2 text-sm font-medium outline-none transition duration-75', $inactiveItemClasses => (! $hasAlpineActiveClasses) && (! $active), $activeItemClasses => (! $hasAlpineActiveClasses) && $active, ]) diff --git a/packages/tables/src/Columns/Summarizers/Summarizer.php b/packages/tables/src/Columns/Summarizers/Summarizer.php index 7c856aa74de..5059c3863d2 100644 --- a/packages/tables/src/Columns/Summarizers/Summarizer.php +++ b/packages/tables/src/Columns/Summarizers/Summarizer.php @@ -111,7 +111,7 @@ function (EloquentBuilder $relatedQuery) use ($baseQuery, $query): EloquentBuild ->prepend('pivot_'); $isPivotAttributeSelected = collect($query->getQuery()->getColumns()) - ->contains(fn(string $column): bool => str($column)->endsWith(" as {$pivotAttribute}")); + ->contains(fn (string $column): bool => str($column)->endsWith(" as {$pivotAttribute}")); $attribute = $isPivotAttributeSelected ? $pivotAttribute : $attribute; @@ -119,7 +119,7 @@ function (EloquentBuilder $relatedQuery) use ($baseQuery, $query): EloquentBuild if ($isPivotAttributeSelected) { $query->getQuery()->columns = array_filter( $query->getQuery()->columns, - fn(mixed $column): bool => $column !== "{$query->getQuery()->joins[0]->table}.*", + fn (mixed $column): bool => $column !== "{$query->getQuery()->joins[0]->table}.*", ); } }