schema([ Forms\Components\Section::make('基本資訊') ->schema([ Forms\Components\TextInput::make('name') ->label('姓名') ->required() ->maxLength(255), Forms\Components\TextInput::make('title') ->label('頭銜') ->maxLength(255), Forms\Components\Select::make('member_type') ->label('成員類型') ->required() ->options([ 'board' => '董事成員', 'executive' => '執行成員', ]) ->default('board'), Forms\Components\Select::make('status') ->label('狀態') ->required() ->options([ 'draft' => '草稿', 'publish' => '已發布', ]) ->default('draft'), Forms\Components\TextInput::make('sort') ->label('排序') ->numeric() ->default(999) ->helperText('數字越小排序越前面'), ]) ->columns(2), Forms\Components\Section::make('照片與內容') ->schema([ Forms\Components\TextInput::make('portrait') ->label('照片連結') ->url() ->maxLength(500) ->helperText('成員照片 URL'), Forms\Components\Textarea::make('positions') ->label('職務') ->rows(5) ->helperText('多個職務請用換行分隔'), Forms\Components\Textarea::make('text') ->label('簡介') ->rows(10) ->helperText('成員簡介文字'), ]) ->columnSpanFull(), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('sort') ->label('排序') ->numeric() ->sortable(), Tables\Columns\TextColumn::make('name') ->label('姓名') ->searchable() ->sortable(), Tables\Columns\TextColumn::make('title') ->label('頭銜') ->searchable(), Tables\Columns\BadgeColumn::make('member_type') ->label('類型') ->formatStateUsing(fn (string $state): string => match ($state) { 'board' => '董事成員', 'executive' => '執行成員', default => $state, }) ->colors([ 'primary' => 'board', 'success' => 'executive', ]), Tables\Columns\BadgeColumn::make('status') ->label('狀態') ->formatStateUsing(fn (string $state): string => match ($state) { 'draft' => '草稿', 'publish' => '已發布', default => $state, }) ->colors([ 'warning' => 'draft', 'success' => 'publish', ]), Tables\Columns\TextColumn::make('created_at') ->label('建立時間') ->dateTime('Y-m-d H:i') ->sortable() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('updated_at') ->label('更新時間') ->dateTime('Y-m-d H:i') ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ Tables\Filters\SelectFilter::make('member_type') ->label('成員類型') ->options([ 'board' => '董事成員', 'executive' => '執行成員', ]), Tables\Filters\SelectFilter::make('status') ->label('狀態') ->options([ 'draft' => '草稿', 'publish' => '已發布', ]), ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]) ->defaultSort('sort', 'asc'); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListMembers::route('/'), 'create' => Pages\CreateMember::route('/create'), 'edit' => Pages\EditMember::route('/{record}/edit'), ]; } }