M3: Filament 后台资源(文章/分类/评论/媒体/用户/友链)+ 博客设置页 + 仪表盘统计
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class MediaTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
ImageColumn::make('preview')
|
||||
->label('预览')
|
||||
->state(fn ($record) => $record->getCustomProperty('isimage') ? $record->getUrl() : null)
|
||||
->circular()
|
||||
->defaultImageUrl('/images/file-icon.png'),
|
||||
TextColumn::make('file_name')
|
||||
->label('文件名')
|
||||
->searchable()
|
||||
->url(fn ($record) => $record->getUrl())
|
||||
->openUrlInNewTab(),
|
||||
TextColumn::make('collection_name')
|
||||
->label('用途')
|
||||
->badge()
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'cover' => '封面',
|
||||
'attachments' => '附件',
|
||||
default => $state,
|
||||
}),
|
||||
TextColumn::make('model_type')
|
||||
->label('关联')
|
||||
->formatStateUsing(fn ($state) => class_basename((string) $state)),
|
||||
TextColumn::make('model_id')
|
||||
->label('ID'),
|
||||
TextColumn::make('size')
|
||||
->label('大小')
|
||||
->formatStateUsing(fn ($state) => number_format((float) $state / 1024, 1).' KB'),
|
||||
TextColumn::make('custom_properties.downloads')
|
||||
->label('下载'),
|
||||
TextColumn::make('created_at')
|
||||
->label('上传时间')
|
||||
->dateTime('Y-m-d H:i'),
|
||||
])
|
||||
->filters([
|
||||
\Filament\Tables\Filters\SelectFilter::make('collection_name')
|
||||
->label('用途')
|
||||
->options([
|
||||
'attachments' => '附件',
|
||||
'cover' => '封面',
|
||||
]),
|
||||
])
|
||||
->recordActions([
|
||||
\Filament\Actions\EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user