81 lines
2.3 KiB
PHP
81 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Filament\Resources;
|
||
|
|
|
||
|
|
use App\Filament\Resources\SiteSettingResource\Pages;
|
||
|
|
use App\Filament\Resources\SiteSettingResource\RelationManagers;
|
||
|
|
use App\Models\SiteSetting;
|
||
|
|
use Filament\Forms;
|
||
|
|
use Filament\Forms\Components\TextInput;
|
||
|
|
use Filament\Forms\Components\Textarea;
|
||
|
|
use Filament\Forms\Form;
|
||
|
|
use Filament\Resources\Resource;
|
||
|
|
use Filament\Tables;
|
||
|
|
use Filament\Tables\Columns\TextColumn;
|
||
|
|
use Filament\Tables\Table;
|
||
|
|
|
||
|
|
class SiteSettingResource extends Resource
|
||
|
|
{
|
||
|
|
protected static ?string $model = SiteSetting::class;
|
||
|
|
protected static ?string $slug = 'site-setting-records';
|
||
|
|
|
||
|
|
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('key')
|
||
|
|
->label('键')
|
||
|
|
->required()
|
||
|
|
->maxLength(255),
|
||
|
|
Textarea::make('value')
|
||
|
|
->label('值')
|
||
|
|
->rows(3)
|
||
|
|
->nullable(),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function table(Table $table): Table
|
||
|
|
{
|
||
|
|
return $table
|
||
|
|
->columns([
|
||
|
|
TextColumn::make('key')->label('键')->searchable()->sortable(),
|
||
|
|
TextColumn::make('value')->label('值')->limit(50),
|
||
|
|
TextColumn::make('updated_at')->label('更新时间')->dateTime(),
|
||
|
|
])
|
||
|
|
->filters([
|
||
|
|
//
|
||
|
|
])
|
||
|
|
->actions([
|
||
|
|
Tables\Actions\EditAction::make(),
|
||
|
|
])
|
||
|
|
->bulkActions([
|
||
|
|
Tables\Actions\BulkActionGroup::make([
|
||
|
|
Tables\Actions\DeleteBulkAction::make(),
|
||
|
|
]),
|
||
|
|
])
|
||
|
|
->emptyStateActions([
|
||
|
|
Tables\Actions\CreateAction::make(),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function getRelations(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
//
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function getPages(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'index' => Pages\ListSiteSettings::route('/'),
|
||
|
|
'create' => Pages\CreateSiteSetting::route('/create'),
|
||
|
|
'edit' => Pages\EditSiteSetting::route('/{record}/edit'),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|