90 lines
2.5 KiB
PHP
90 lines
2.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Filament\Resources;
|
||
|
|
|
||
|
|
use App\Filament\Resources\ContactMessageResource\Pages;
|
||
|
|
use App\Filament\Resources\ContactMessageResource\RelationManagers;
|
||
|
|
use App\Models\ContactMessage;
|
||
|
|
use Filament\Forms;
|
||
|
|
use Filament\Forms\Components\Textarea;
|
||
|
|
use Filament\Forms\Components\TextInput;
|
||
|
|
use Filament\Forms\Form;
|
||
|
|
use Filament\Resources\Resource;
|
||
|
|
use Filament\Tables;
|
||
|
|
use Filament\Tables\Columns\TextColumn;
|
||
|
|
use Filament\Tables\Table;
|
||
|
|
|
||
|
|
class ContactMessageResource extends Resource
|
||
|
|
{
|
||
|
|
protected static ?string $model = ContactMessage::class;
|
||
|
|
|
||
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||
|
|
protected static ?string $navigationLabel = '联系表单';
|
||
|
|
protected static ?string $navigationGroup = '站点设置';
|
||
|
|
|
||
|
|
public static function form(Form $form): Form
|
||
|
|
{
|
||
|
|
return $form
|
||
|
|
->schema([
|
||
|
|
TextInput::make('name')
|
||
|
|
->label('姓名')
|
||
|
|
->disabled()
|
||
|
|
->dehydrated(false),
|
||
|
|
TextInput::make('email')
|
||
|
|
->label('邮箱')
|
||
|
|
->disabled()
|
||
|
|
->dehydrated(false),
|
||
|
|
Textarea::make('content')
|
||
|
|
->label('内容')
|
||
|
|
->disabled()
|
||
|
|
->dehydrated(false)
|
||
|
|
->columnSpanFull(),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function table(Table $table): Table
|
||
|
|
{
|
||
|
|
return $table
|
||
|
|
->columns([
|
||
|
|
TextColumn::make('name')->label('姓名')->searchable(),
|
||
|
|
TextColumn::make('email')->label('邮箱')->searchable(),
|
||
|
|
TextColumn::make('created_at')->label('提交时间')->dateTime(),
|
||
|
|
])
|
||
|
|
->filters([
|
||
|
|
//
|
||
|
|
])
|
||
|
|
->actions([
|
||
|
|
Tables\Actions\EditAction::make(),
|
||
|
|
])
|
||
|
|
->bulkActions([
|
||
|
|
Tables\Actions\BulkActionGroup::make([
|
||
|
|
Tables\Actions\DeleteBulkAction::make(),
|
||
|
|
]),
|
||
|
|
])
|
||
|
|
->emptyStateActions([
|
||
|
|
//
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function getRelations(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
//
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function getPages(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'index' => Pages\ListContactMessages::route('/'),
|
||
|
|
'edit' => Pages\EditContactMessage::route('/{record}/edit'),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function canCreate(): bool
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|