-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 添加商品标签相关的数据模型、仓库和应用服务 - 实现商品标签的创建、编辑和列表展示页面- 在数据库中创建商品标签表 - 更新导航栏显示,增加商品标签相关功能
- Loading branch information
1 parent
e3f1760
commit d653b0d
Showing
8 changed files
with
231 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<?php | ||
|
||
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources; | ||
|
||
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper; | ||
use RedJasmine\FilamentProduct\Clusters\Product; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductTagResource\Pages; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductTagResource\RelationManagers; | ||
use RedJasmine\Product\Application\Tag\Services\ProductTagCommandService; | ||
use RedJasmine\Product\Application\Tag\Services\ProductTagQueryService; | ||
use RedJasmine\Product\Application\Tag\UserCases\Commands\ProductTagCreateCommand; | ||
use RedJasmine\Product\Application\Tag\UserCases\Commands\ProductTagDeleteCommand; | ||
use RedJasmine\Product\Application\Tag\UserCases\Commands\ProductTagUpdateCommand; | ||
use RedJasmine\Product\Domain\Tag\Models\Enums\TagStatusEnum; | ||
use RedJasmine\Product\Domain\Tag\Models\ProductTag; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\SoftDeletingScope; | ||
|
||
class ProductTagResource extends Resource | ||
{ | ||
protected static ?string $model = ProductTag::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-tag'; | ||
|
||
protected static ?string $cluster = Product::class; | ||
protected static ?int $navigationSort = 5; | ||
|
||
use ResourcePageHelper; | ||
|
||
protected static ?string $commandService = ProductTagCommandService::class; | ||
protected static ?string $queryService = ProductTagQueryService::class; | ||
protected static ?string $createCommand = ProductTagCreateCommand::class; | ||
protected static ?string $updateCommand = ProductTagUpdateCommand::class; | ||
protected static ?string $deleteCommand = ProductTagDeleteCommand::class; | ||
protected static bool $onlyOwner = true; | ||
|
||
public static function getModelLabel() : string | ||
{ | ||
return __('red-jasmine-product::product-tag.labels.tag'); | ||
} | ||
|
||
public static function form(Form $form) : Form | ||
{ | ||
return $form | ||
->schema([ | ||
...static::ownerFormSchemas(), | ||
Forms\Components\TextInput::make('name') | ||
->label(__('red-jasmine-product::product-tag.fields.name')) | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('description') | ||
->label(__('red-jasmine-product::product-tag.fields.description')) | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('icon') | ||
->label(__('red-jasmine-product::product-tag.fields.icon')) | ||
->maxLength(255), | ||
Forms\Components\ColorPicker::make('color') | ||
->label(__('red-jasmine-product::product-tag.fields.color')) | ||
, | ||
Forms\Components\TextInput::make('cluster') | ||
->label(__('red-jasmine-product::product-tag.fields.cluster')) | ||
->maxLength(255), | ||
Forms\Components\TextInput::make('sort') | ||
->label(__('red-jasmine-product::product-tag.fields.sort')) | ||
->required() | ||
->numeric() | ||
->default(0), | ||
Forms\Components\Toggle::make('is_show') | ||
->label(__('red-jasmine-product::product-tag.fields.is_show')) | ||
->required() | ||
->default(1), | ||
Forms\Components\Toggle::make('is_public') | ||
->label(__('red-jasmine-product::product-tag.fields.is_public')) | ||
->required() | ||
->default(0), | ||
Forms\Components\Radio::make('status') | ||
->label(__('red-jasmine-product::product-tag.fields.status')) | ||
->required() | ||
->inlineLabel() | ||
->inline() | ||
->default(TagStatusEnum::ENABLE) | ||
->options(TagStatusEnum::options()), | ||
...static::operateFormSchemas(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table) : Table | ||
{ | ||
return $table | ||
->columns([ | ||
...static::ownerTableColumns(), | ||
Tables\Columns\TextColumn::make('name') | ||
->label(__('red-jasmine-product::product-tag.fields.name')) | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('description') | ||
->label(__('red-jasmine-product::product-tag.fields.description')) | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('icon') | ||
->label(__('red-jasmine-product::product-tag.fields.icon')) | ||
, | ||
Tables\Columns\ColorColumn::make('color') | ||
->label(__('red-jasmine-product::product-tag.fields.color')) | ||
, | ||
Tables\Columns\TextColumn::make('cluster') | ||
->label(__('red-jasmine-product::product-tag.fields.cluster')) | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('sort') | ||
->label(__('red-jasmine-product::product-tag.fields.sort')) | ||
->numeric() | ||
->sortable(), | ||
Tables\Columns\IconColumn::make('is_show') | ||
->label(__('red-jasmine-product::product-tag.fields.is_show')) | ||
->boolean() | ||
->sortable(), | ||
Tables\Columns\IconColumn::make('is_public') | ||
->label(__('red-jasmine-product::product-tag.fields.is_public')) | ||
->boolean() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('status') | ||
->label(__('red-jasmine-product::product-tag.fields.status')) | ||
->enum(), | ||
|
||
...static::operateTableColumns() | ||
]) | ||
->filters([ | ||
Tables\Filters\TrashedFilter::make(), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
Tables\Actions\ForceDeleteBulkAction::make(), | ||
Tables\Actions\RestoreBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getRelations() : array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages() : array | ||
{ | ||
return [ | ||
'index' => Pages\ListProductTags::route('/'), | ||
'create' => Pages\CreateProductTag::route('/create'), | ||
'edit' => Pages\EditProductTag::route('/{record}/edit'), | ||
]; | ||
} | ||
|
||
public static function getEloquentQuery() : Builder | ||
{ | ||
return parent::getEloquentQuery() | ||
->withoutGlobalScopes([ | ||
SoftDeletingScope::class, | ||
]); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Clusters/Product/Resources/ProductTagResource/Pages/CreateProductTag.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductTagResource\Pages; | ||
|
||
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductTagResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateProductTag extends CreateRecord | ||
{ | ||
protected static string $resource = ProductTagResource::class; | ||
use ResourcePageHelper; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Clusters/Product/Resources/ProductTagResource/Pages/EditProductTag.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductTagResource\Pages; | ||
|
||
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductTagResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditProductTag extends EditRecord | ||
{ | ||
protected static string $resource = ProductTagResource::class; | ||
use ResourcePageHelper; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
Actions\ForceDeleteAction::make(), | ||
Actions\RestoreAction::make(), | ||
]; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Clusters/Product/Resources/ProductTagResource/Pages/ListProductTags.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductTagResource\Pages; | ||
|
||
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductTagResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListProductTags extends ListRecords | ||
{ | ||
use ResourcePageHelper; | ||
protected static string $resource = ProductTagResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |