Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\Media\Pages;
|
|
|
|
use App\Filament\Resources\Media\MediaResource;
|
|
use App\Models\Media;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ListMedia extends ListRecords
|
|
{
|
|
protected static string $resource = MediaResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
// The media table is derived, so rebuilding it is always safe and
|
|
// is the answer to "I changed the widths, now what?".
|
|
Action::make('reprocess_all')
|
|
->label(__('panel.media.actions.reprocess_all'))
|
|
->icon('heroicon-o-arrow-path')
|
|
->color('gray')
|
|
->requiresConfirmation()
|
|
->modalDescription(__('panel.media.actions.reprocess_all_hint'))
|
|
->visible(fn () => Auth::user()?->can('media.view_any'))
|
|
->action(function (): void {
|
|
Media::query()->update(['processed_at' => null]);
|
|
|
|
Notification::make()
|
|
->title(__('panel.media.actions.reprocess_queued'))
|
|
->success()
|
|
->send();
|
|
}),
|
|
];
|
|
}
|
|
|
|
public function getSubheading(): ?string
|
|
{
|
|
$total = Media::query()->get()->sum(fn (Media $m) => $m->totalSize());
|
|
|
|
return __('panel.media.subheading', [
|
|
'count' => Media::query()->count(),
|
|
'size' => round($total / 1024 / 1024, 1),
|
|
]);
|
|
}
|
|
}
|