author_name; } public static function form(Schema $schema): Schema { return $schema->components([ Section::make(__('panel.testimonials.sections.quote')) ->description(__('panel.testimonials.sections.quote_hint')) ->schema([ Select::make('original_locale') ->label(__('panel.testimonials.fields.original_locale')) ->helperText(__('panel.testimonials.fields.original_locale_hint')) ->options(fn () => collect(config('locales.supported')) ->map(fn (array $meta, string $code) => $meta['native'] ?? $code) ->all()) ->default(config('locales.default')) ->required(), TranslatableTabs::make(fn (string $locale, bool $isDefault) => [ Textarea::make("quote.{$locale}") ->label(__('panel.testimonials.fields.quote')) ->required($isDefault) ->rows(4) ->maxLength(1000) ->columnSpanFull(), ])->columnSpanFull(), ]), Section::make(__('panel.testimonials.sections.author')) ->columns(2) ->schema([ TextInput::make('author_name') ->label(__('panel.testimonials.fields.author_name')) ->required() ->maxLength(255), DatePicker::make('given_at') ->label(__('panel.testimonials.fields.given_at')), TranslatableTabs::make(fn (string $locale) => [ TextInput::make("author_role.{$locale}") ->label(__('panel.testimonials.fields.author_role')) ->maxLength(255) ->columnSpanFull(), ])->columnSpanFull(), FileUpload::make('avatar') ->label(__('panel.testimonials.fields.avatar')) ->image() ->avatar() ->disk(config('media.disk')) ->directory('testimonials') ->columnSpanFull(), ]), Section::make(__('panel.testimonials.sections.about')) ->description(__('panel.testimonials.sections.about_hint')) ->columns(3) ->schema([ Select::make('client_id') ->label(__('panel.testimonials.fields.client')) ->relationship('client', 'name') ->searchable() ->preload(), Select::make('project_id') ->label(__('panel.testimonials.fields.project')) ->relationship('project', 'title->'.config('locales.default')) ->getOptionLabelFromRecordUsing(TranslatedOptionLabel::using('title')) ->searchable() ->preload(), Select::make('service_id') ->label(__('panel.testimonials.fields.service')) ->relationship('service', 'title->'.config('locales.default')) ->getOptionLabelFromRecordUsing(TranslatedOptionLabel::using('title')) ->searchable() ->preload(), Toggle::make('is_public') ->label(__('panel.testimonials.fields.is_public')) ->default(true), TextInput::make('position') ->label(__('panel.testimonials.fields.position')) ->numeric() ->default(0), ]), ]); } public static function table(Table $table): Table { $locale = app()->getLocale(); return $table ->defaultSort('position') ->reorderable('position') ->columns([ ImageColumn::make('avatar') ->label('') ->circular() ->disk(config('media.disk')), TextColumn::make('quote') ->label(__('panel.testimonials.fields.quote')) ->state(fn (Testimonial $record) => $record->getTranslation('quote', $locale, false) ?: null) ->wrap() ->limit(120), TextColumn::make('author_name') ->label(__('panel.testimonials.fields.author_name')) ->description(fn (Testimonial $record) => $record->getTranslation('author_role', $locale, false) ?: null) ->searchable(), // Whose words these are matters: a quote with nothing behind // it is a sentence somebody wrote about themselves. TextColumn::make('client.name') ->label(__('panel.testimonials.fields.client')) ->badge() ->color('gray') ->placeholder('—') ->toggleable(), TextColumn::make('original_locale') ->label(__('panel.testimonials.fields.original_locale')) ->badge() ->color('gray') ->formatStateUsing(fn (string $state) => config("locales.supported.{$state}.native", $state)) ->toggleable(), IconColumn::make('is_public') ->label(__('panel.testimonials.fields.is_public')) ->boolean(), ]) ->filters([ TernaryFilter::make('is_public')->label(__('panel.testimonials.fields.is_public')), SelectFilter::make('client') ->label(__('panel.testimonials.fields.client')) ->relationship('client', 'name') ->searchable() ->preload(), TrashedFilter::make(), ]) ->recordActions([ EditAction::make(), DeleteAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ForceDeleteBulkAction::make(), RestoreBulkAction::make(), ]), ]); } /** * @return array */ public static function getGloballySearchableAttributes(): array { return ['author_name']; } public static function getRelations(): array { return [ RevisionsRelationManager::class, ]; } public static function getPages(): array { return [ 'index' => ListTestimonials::route('/'), 'create' => CreateTestimonial::route('/create'), 'edit' => EditTestimonial::route('/{record}/edit'), ]; } }