|
|
@@ -51,8 +51,18 @@ class NewsResource extends Resource
|
|
51
|
51
|
->options(NewsCategory::get()->pluck("name","id"))
|
|
52
|
52
|
->label("文章分類")
|
|
53
|
53
|
->columnSpan(1)
|
|
|
54
|
+ ->default(1)
|
|
54
|
55
|
->native(false)
|
|
55
|
|
- ->Live(),
|
|
|
56
|
+ ->afterStateHydrated(function ($component, $state) {
|
|
|
57
|
+ // ✅ 如果沒有值,設定為第一項
|
|
|
58
|
+ if (empty($state)) {
|
|
|
59
|
+ $firstCategoryId = NewsCategory::first()?->id;
|
|
|
60
|
+ if ($firstCategoryId) {
|
|
|
61
|
+ $component->state($firstCategoryId);
|
|
|
62
|
+ }
|
|
|
63
|
+ }
|
|
|
64
|
+ })
|
|
|
65
|
+ ->hidden(),
|
|
56
|
66
|
])->columnSpanFull()->columns(2),
|
|
57
|
67
|
Group::make()->schema([
|
|
58
|
68
|
DatePicker::make('post_date')
|