Skip to content

Commit

Permalink
产品模块添加自定义属性和表单功能
Browse files Browse the repository at this point in the history
- 在产品模型中添加自定义属性和表单字段
- 实现产品自定义属性和表单的增删改查
- 更新产品相关数据库表结构,增加自定义属性和表单字段
- 在前端界面中展示产品自定义属性和表单
  • Loading branch information
liushoukun committed Oct 12, 2024
1 parent a16a579 commit 2438198
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/FilamentCoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace RedJasmine\FilamentCore;

use Filament\Forms\Components\Select;
use Filament\Forms\Components\ToggleButtons;
use Filament\Support\Assets\Asset;
use Filament\Support\Facades\FilamentAsset;
Expand Down Expand Up @@ -103,6 +104,12 @@ public function packageBooted() : void
->icon(fn($state) => $state->getIcon());
});

Select::macro('useEnum', function (string $enumClassName) {
return $this->enum($enumClassName)
->options($enumClassName::options())
;
});

ToggleButtons::macro('useEnum', function (string $enumClassName) {

return $this->enum($enumClassName)
Expand Down
1 change: 1 addition & 0 deletions src/Helpers/ResourcePageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ protected function handleRecordCreation(array $data) : Model
{



$resource = static::getResource();

try {
Expand Down

0 comments on commit 2438198

Please sign in to comment.