Skip to content

Commit

Permalink
fix: n+1 query on attributes table (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
mckenziearts authored Jan 14, 2025
1 parent 5ecb5bd commit 33cc2a1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@php
$total = $this->table->getRecords()->total();
@endphp

<x-shopper::container class="py-5">
<x-shopper::breadcrumb :back="route('shopper.products.index')">
<x-untitledui-chevron-left class="size-4 shrink-0 text-gray-300 dark:text-gray-600" />
Expand Down
5 changes: 2 additions & 3 deletions packages/admin/routes/admin/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
});

if (\Shopper\Feature::enabled('attribute')) {
Route::prefix('attributes')->as('attributes.')->group(function (): void {
Route::get('/', config('shopper.components.product.pages.attribute-index'))->name('index');
});
Route::get('attributes', config('shopper.components.product.pages.attribute-index'))
->name('attributes.index');
}
6 changes: 1 addition & 5 deletions packages/admin/src/Livewire/Pages/Attribute/Browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Filament\Tables\Table;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Livewire\Attributes\On;
use Shopper\Components\Tables\IconColumn;
use Shopper\Core\Models\Attribute;
use Shopper\Livewire\Pages\AbstractPageComponent;
Expand Down Expand Up @@ -143,12 +142,9 @@ public function table(Table $table): Table
]);
}

#[On('attribute-save')]
public function render(): View
{
return view('shopper::livewire.pages.attributes.browse', [
'total' => Attribute::query()->count(),
])
return view('shopper::livewire.pages.attributes.browse')
->title(__('shopper::pages/attributes.menu'));
}
}

0 comments on commit 33cc2a1

Please sign in to comment.