-
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
f62ae8c
commit 657d2fa
Showing
58 changed files
with
2,678 additions
and
157 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
// config for Redjasmine/FilamentProduct | ||
// config for RedJasmine/FilamentProduct | ||
return [ | ||
|
||
]; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
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 |
---|---|---|
|
@@ -3,4 +3,6 @@ | |
// translations for Redjasmine/FilamentProduct | ||
return [ | ||
// | ||
|
||
'label'=>'Product', | ||
]; |
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,8 @@ | ||
<?php | ||
|
||
// translations for RedJasmine/FilamentProduct | ||
return [ | ||
// | ||
|
||
'label' => '商品', | ||
]; |
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,25 @@ | ||
<?php | ||
|
||
namespace RedJasmine\FilamentProduct\Clusters; | ||
|
||
|
||
use Filament\Clusters\Cluster; | ||
|
||
class Product extends Cluster | ||
{ | ||
protected static ?string $navigationIcon = 'heroicon-o-shopping-bag'; | ||
|
||
|
||
public static function getNavigationLabel() : string | ||
{ | ||
|
||
return __('filament-product::product.label'); | ||
} | ||
|
||
|
||
public static function getClusterBreadcrumb() : ?string | ||
{ | ||
return __('filament-product::product.label'); | ||
} | ||
|
||
} |
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,56 @@ | ||
<?php | ||
|
||
namespace RedJasmine\FilamentProduct\Clusters\Product\Pages; | ||
|
||
|
||
use Filament\Pages\Page; | ||
use Filament\Widgets\Widget; | ||
use Filament\Widgets\WidgetConfiguration; | ||
use Illuminate\Contracts\Support\Htmlable; | ||
use RedJasmine\FilamentProduct\Clusters\Product; | ||
|
||
class Dashboard extends Page | ||
{ | ||
|
||
|
||
|
||
protected static ?string $navigationIcon = 'heroicon-o-home'; | ||
|
||
public static function getNavigationLabel() : string | ||
{ | ||
return '商品中心'; | ||
} | ||
|
||
|
||
public function getTitle() : string|Htmlable | ||
{ | ||
return '商品中心'; | ||
} | ||
|
||
protected static ?string $slug = 'dashboard'; | ||
protected static ?int $navigationSort = -3; | ||
protected static ?string $cluster = Product::class; | ||
protected static string $view = 'filament-panels::pages.dashboard'; | ||
|
||
/** | ||
* @return array<class-string<Widget> | WidgetConfiguration> | ||
*/ | ||
public function getVisibleWidgets() : array | ||
{ | ||
return $this->filterVisibleWidgets($this->getWidgets()); | ||
} | ||
|
||
public function getWidgets() : array | ||
{ | ||
|
||
return [ | ||
|
||
]; | ||
} | ||
|
||
public function getColumns() : int|string|array | ||
{ | ||
return 2; | ||
} | ||
|
||
} |
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,142 @@ | ||
<?php | ||
|
||
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources; | ||
|
||
use App\Filament\Clusters\Product\Resources\BrandResource\RelationManagers; | ||
use CodeWithDennis\FilamentSelectTree\SelectTree; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
use Illuminate\Database\Eloquent\Model; | ||
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper; | ||
use RedJasmine\FilamentProduct\Clusters\Product; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource\Pages\CreateBrand; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource\Pages\EditBrand; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource\Pages\ListBrands; | ||
use RedJasmine\Product\Application\Brand\Services\BrandCommandService; | ||
use RedJasmine\Product\Application\Brand\Services\BrandQueryService; | ||
use RedJasmine\Product\Application\Brand\UserCases\Commands\BrandCreateCommand; | ||
use RedJasmine\Product\Application\Brand\UserCases\Commands\BrandDeleteCommand; | ||
use RedJasmine\Product\Application\Brand\UserCases\Commands\BrandUpdateCommand; | ||
use RedJasmine\Product\Domain\Brand\Models\Brand; | ||
use RedJasmine\Product\Domain\Brand\Models\Enums\BrandStatusEnum; | ||
|
||
class BrandResource extends Resource | ||
{ | ||
protected static ?int $navigationSort = 2; | ||
protected static ?string $cluster = Product::class; | ||
protected static ?string $model = Brand::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-swatch'; | ||
|
||
use ResourcePageHelper; | ||
|
||
protected static ?string $commandService = BrandCommandService::class; | ||
protected static ?string $queryService = BrandQueryService::class; | ||
protected static ?string $createCommand = BrandCreateCommand::class; | ||
protected static ?string $updateCommand = BrandUpdateCommand::class; | ||
protected static ?string $deleteCommand = BrandDeleteCommand::class; | ||
|
||
|
||
public static function getModelLabel() : string | ||
{ | ||
return __('red-jasmine.product::brand.labels.brand'); | ||
} | ||
|
||
public static function form(Form $form) : Form | ||
{ | ||
return $form | ||
->schema([ | ||
SelectTree::make('parent_id') | ||
->relationship( | ||
relationship: 'parent', | ||
titleAttribute: 'name', | ||
parentAttribute: 'parent_id', | ||
modifyQueryUsing: fn($query, Forms\Get $get, ?Model $record) => $query->when($record?->getKey(), fn($query, $value) => $query->where('id', '<>', $value)), | ||
modifyChildQueryUsing: fn($query, Forms\Get $get, ?Model $record) => $query->when($record?->getKey(), fn($query, $value) => $query->where('id', '<>', $value)), | ||
) | ||
// ->required() | ||
->searchable() | ||
->default(0) | ||
->enableBranchNode() | ||
->parentNullValue(0) | ||
, | ||
Forms\Components\TextInput::make('name') | ||
->label(__('red-jasmine.product::brand.fields.name')) | ||
->required(), | ||
Forms\Components\TextInput::make('description') | ||
->label(__('red-jasmine.product::brand.fields.description')) | ||
|
||
->maxLength(255), | ||
Forms\Components\TextInput::make('english_name') | ||
->label(__('red-jasmine.product::brand.fields.english_name')) | ||
->required(), | ||
Forms\Components\TextInput::make('initial') | ||
->maxLength(1) | ||
->label(__('red-jasmine.product::brand.fields.initial'))->required(), | ||
Forms\Components\TextInput::make('sort') | ||
->label(__('red-jasmine.product::brand.fields.sort')) | ||
->default(0)->required()->numeric()->minValue(0), | ||
Forms\Components\Radio::make('is_show') | ||
->label(__('red-jasmine.product::brand.fields.is_show')) | ||
->boolean()->inline()->default(true), | ||
Forms\Components\Radio::make('status')->label(__('red-jasmine.product::brand.fields.status')) | ||
->options(BrandStatusEnum::options()) | ||
->inline()->default(BrandStatusEnum::ENABLE->value), | ||
])->columns(1); | ||
} | ||
|
||
public static function table(Table $table) : Table | ||
{ | ||
|
||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('id'), | ||
Tables\Columns\TextColumn::make('parent.name'), | ||
Tables\Columns\TextColumn::make('name') | ||
->label(__('red-jasmine.product::brand.fields.name')) | ||
->searchable(), | ||
|
||
Tables\Columns\TextColumn::make('initial') | ||
->label(__('red-jasmine.product::brand.fields.initial')), | ||
Tables\Columns\TextColumn::make('english_name') | ||
->label(__('red-jasmine.product::brand.fields.english_name')), | ||
Tables\Columns\ImageColumn::make('logo')->label(__('red-jasmine.product::brand.fields.logo')), | ||
Tables\Columns\IconColumn::make('is_show')->label(__('red-jasmine.product::brand.fields.is_show'))->boolean(), | ||
Tables\Columns\TextColumn::make('sort')->label(__('red-jasmine.product::brand.fields.sort'))->sortable(), | ||
Tables\Columns\TextColumn::make('status')->label(__('red-jasmine.product::brand.fields.status')) | ||
->badge()->formatStateUsing(fn($state) => $state->label())->color(fn($state) => $state->color()), | ||
|
||
|
||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getRelations() : array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages() : array | ||
{ | ||
return [ | ||
'index' => ListBrands::route('/'), | ||
'create' => CreateBrand::route('/create'), | ||
'edit' => EditBrand::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Clusters/Product/Resources/BrandResource/Pages/CreateBrand.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,19 @@ | ||
<?php | ||
|
||
namespace RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource\Pages; | ||
|
||
use Filament\Resources\Pages\CreateRecord; | ||
use RedJasmine\FilamentCore\FilamentResource\ResourcePageHelper; | ||
use RedJasmine\FilamentProduct\Clusters\Product\Resources\BrandResource; | ||
|
||
class CreateBrand extends CreateRecord | ||
{ | ||
|
||
use ResourcePageHelper; | ||
|
||
protected static string $resource = BrandResource::class; | ||
|
||
|
||
} | ||
|
||
|
Oops, something went wrong.