Skip to content

Commit

Permalink
为产品列表页面添加分类选项和过滤器
Browse files Browse the repository at this point in the history
- 在产品列表页面添加了四个分类选项:全部、在售、下架和草稿
- 在过滤器中增加了产品类型和运输类型的选择过滤
- 添加了删除操作到产品表格的操作列表
  • Loading branch information
liushoukun committed Oct 10, 2024
1 parent 7230057 commit b195e09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Clusters/Product/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,15 @@ public static function table(Table $table) : Table
->label(__('red-jasmine-product::product.fields.status'))
->options(ProductStatusEnum::options()),

Tables\Filters\SelectFilter::make('product_type')
->multiple()
->label(__('red-jasmine-product::product.fields.product_type'))
->options(ProductTypeEnum::options()),

Tables\Filters\SelectFilter::make('shipping_type')
->multiple()
->label(__('red-jasmine-product::product.fields.shipping_type'))
->options(ShippingTypeEnum::options()),

Tables\Filters\TrashedFilter::make(),
], layout: Tables\Enums\FiltersLayout::AboveContentCollapsible)
Expand All @@ -722,6 +731,7 @@ public static function table(Table $table) : Table
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@

use Filament\Actions;
use Filament\Infolists\Infolist;
use Filament\Resources\Components\Tab;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Database\Eloquent\Builder;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductResource;
use RedJasmine\Product\Domain\Product\Models\Enums\ProductStatusEnum;

class ListProducts extends ListRecords
{
protected static string $resource = ProductResource::class;


public function getTabs() : array
{
return [
'all' => Tab::make()->label('ALL'),
'sale' => Tab::make()->label('在售')->modifyQueryUsing(fn(Builder $query) => $query->sale()),
'off_shelf' => Tab::make()->label('下架')->modifyQueryUsing(fn(Builder $query) => $query->offShelf()),
'draft' => Tab::make()->label('未上架')->modifyQueryUsing(fn(Builder $query) => $query->draft()),

];
}

protected function getHeaderActions(): array
protected function getHeaderActions() : array
{
return [
Actions\CreateAction::make(),
Expand Down

0 comments on commit b195e09

Please sign in to comment.