where('type', static::voiceType()); } public static function form(Form $form): Form { return $form ->schema([ Forms\Components\Section::make('基本資訊') ->schema([ Forms\Components\Hidden::make('type') ->default(static::voiceType()) ->required(), Forms\Components\Select::make('status') ->label('狀態') ->required() ->options([ 'draft' => '草稿', 'publish' => '已發布', ]) ->default('draft'), Forms\Components\TextInput::make('sort') ->label('排序') ->numeric() ->default(999) ->helperText('數字越小排序越前面'), Forms\Components\Toggle::make('featured') ->label('精選') ->default(false), Forms\Components\DateTimePicker::make('published_at') ->label('發布時間') ->helperText('可選,留空表示立即生效(由 status 控制)'), ]) ->columns(2), Forms\Components\Section::make('內容與作者') ->schema([ Forms\Components\RichEditor::make('content_html') ->label('內容(HTML)') ->required() ->columnSpanFull(), Forms\Components\Textarea::make('content_summary') ->label('摘要') ->rows(3) ->columnSpanFull(), Forms\Components\TextInput::make('author_name') ->label('作者姓名') ->required() ->maxLength(255), Forms\Components\TextInput::make('author_title') ->label('作者職稱') ->maxLength(255), Forms\Components\TextInput::make('company_name') ->label('公司名稱') ->maxLength(255), ]) ->columns(2), Forms\Components\Section::make('圖片') ->schema([ Forms\Components\FileUpload::make('company_logo_path') ->label('公司 Logo') ->image() ->disk('uploads') ->directory('voices/logos') ->helperText('上傳後會存到 public/uploads/voices/logos'), Forms\Components\FileUpload::make('image_path') ->label('視覺圖片') ->image() ->disk('uploads') ->directory('voices/images') ->helperText('Partner Carousel 左側大圖'), ]) ->columns(2), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('sort') ->label('排序') ->numeric() ->sortable(), Tables\Columns\TextColumn::make('author_name') ->label('作者') ->searchable() ->sortable(), Tables\Columns\TextColumn::make('company_name') ->label('公司') ->searchable() ->toggleable(), Tables\Columns\IconColumn::make('featured') ->label('精選') ->boolean() ->toggleable(), 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('published_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('status') ->label('狀態') ->options([ 'draft' => '草稿', 'publish' => '已發布', ]), Tables\Filters\TernaryFilter::make('featured') ->label('精選'), ]) ->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\ListPartnerVoices::route('/'), 'create' => Pages\CreatePartnerVoice::route('/create'), 'edit' => Pages\EditPartnerVoice::route('/{record}/edit'), ]; } }