Initial commit: Pireon Admin — headless admin panel and public API

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>
This commit is contained in:
2026-08-19 17:55:27 +02:00
commit 3897113313
534 changed files with 64050 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\Pages;
use App\Filament\Resources\Projects\ProjectResource;
use Filament\Resources\Pages\CreateRecord;
class CreateProject extends CreateRecord
{
protected static string $resource = ProjectResource::class;
}

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\Pages;
use App\Filament\Concerns\WarnsOfConcurrentEditing;
use App\Filament\Resources\Projects\ProjectResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditProject extends EditRecord
{
use WarnsOfConcurrentEditing;
protected static string $resource = ProjectResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\Pages;
use App\Filament\Resources\Projects\ProjectResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListProjects extends ListRecords
{
protected static string $resource = ProjectResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects;
use App\Filament\RelationManagers\ReviewsRelationManager;
use App\Filament\RelationManagers\RevisionsRelationManager;
use App\Filament\Resources\Projects\Pages\CreateProject;
use App\Filament\Resources\Projects\Pages\EditProject;
use App\Filament\Resources\Projects\Pages\ListProjects;
use App\Filament\Resources\Projects\RelationManagers\GalleryRelationManager;
use App\Filament\Resources\Projects\RelationManagers\RepositoriesRelationManager;
use App\Filament\Resources\Projects\Schemas\ProjectForm;
use App\Filament\Resources\Projects\Tables\ProjectsTable;
use App\Models\Project;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use UnitEnum;
class ProjectResource extends Resource
{
protected static ?string $model = Project::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRocketLaunch;
protected static ?int $navigationSort = 1;
public static function getModelLabel(): string
{
return __('panel.projects.label');
}
public static function getPluralModelLabel(): string
{
return __('panel.projects.plural');
}
public static function getNavigationGroup(): string|UnitEnum|null
{
return __('panel.groups.collective');
}
public static function getRecordTitle(?Model $record): ?string
{
return $record?->getTranslation('title', app()->getLocale());
}
/**
* @return array<int, string>
*/
public static function getGloballySearchableAttributes(): array
{
return ['title->'.app()->getLocale()];
}
public static function form(Schema $schema): Schema
{
return ProjectForm::configure($schema);
}
public static function table(Table $table): Table
{
return ProjectsTable::configure($table);
}
public static function getRelations(): array
{
return [
ReviewsRelationManager::class,
RevisionsRelationManager::class,
GalleryRelationManager::class,
RepositoriesRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => ListProjects::route('/'),
'create' => CreateProject::route('/create'),
'edit' => EditProject::route('/{record}/edit'),
];
}
public static function getRecordRouteBindingEloquentQuery(): Builder
{
return parent::getRecordRouteBindingEloquentQuery()
->withoutGlobalScopes([SoftDeletingScope::class]);
}
/**
* Surfaces how many projects are asking for contributors — the number the
* collective most wants to act on.
*/
public static function getNavigationBadge(): ?string
{
$count = static::getModel()::query()->needingHelp()->count();
return $count > 0 ? (string) $count : null;
}
public static function getNavigationBadgeColor(): ?string
{
return 'warning';
}
}

View File

@@ -0,0 +1,142 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\RelationManagers;
use App\Filament\Support\TranslatableTabs;
use App\Models\ImageAttachment;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
/**
* The gallery of a project.
*
* A table rather than a repeater inside the form, because the thing you need
* to see while editing a gallery is the images themselves, and because the
* order matters — it is dragged here rather than typed into a number field.
*/
class GalleryRelationManager extends RelationManager
{
protected static string $relationship = 'images';
public static function getTitle(Model $ownerRecord, string $pageClass): string
{
return __('panel.gallery.title');
}
public static function getBadge(Model $ownerRecord, string $pageClass): ?string
{
$count = $ownerRecord->images()->count();
return $count > 0 ? (string) $count : null;
}
public function form(Schema $schema): Schema
{
return $schema->components([
FileUpload::make('path')
->label(__('panel.gallery.fields.image'))
->image()
// Explicit: the default disk is private, and the frontend runs
// on another host.
->disk(config('media.disk'))
->directory('projects/gallery')
->imageEditor()
->required()
->columnSpanFull(),
TranslatableTabs::make(fn (string $locale) => [
TextInput::make("alt.{$locale}")
->label(__('panel.gallery.fields.alt'))
->helperText(__('panel.gallery.fields.alt_hint'))
->maxLength(255)
->columnSpanFull(),
// Shown to everyone, unlike the alt text. "Before" and
// "after" belong here.
TextInput::make("caption.{$locale}")
->label(__('panel.gallery.fields.caption'))
->helperText(__('panel.gallery.fields.caption_hint'))
->maxLength(255)
->columnSpanFull(),
])->columnSpanFull(),
]);
}
public function table(Table $table): Table
{
$locale = app()->getLocale();
return $table
->defaultSort('position')
->reorderable('position')
// The table shows each image's real dimensions; loaded up front so
// that costs one query rather than one per row.
->modifyQueryUsing(fn (Builder $query) => $query->with('media'))
->columns([
ImageColumn::make('path')
->label('')
->disk(config('media.disk'))
->height(56),
TextColumn::make('caption')
->label(__('panel.gallery.fields.caption'))
->state(fn (ImageAttachment $record) => $record->getTranslation('caption', $locale, false) ?: null)
->placeholder('—')
->wrap(),
TextColumn::make('alt')
->label(__('panel.gallery.fields.alt'))
->state(fn (ImageAttachment $record) => $record->getTranslation('alt', $locale, false) ?: null)
// An image nobody described is the one worth spotting from
// the listing.
->placeholder(__('panel.gallery.missing_alt'))
->color(fn (ImageAttachment $record) => $record->getTranslation('alt', $locale, false)
? null
: 'warning')
->wrap()
->toggleable(),
TextColumn::make('media.width')
->label(__('panel.gallery.fields.size'))
->state(fn (ImageAttachment $record) => $record->media?->width
? "{$record->media->width}×{$record->media->height}"
: __('panel.gallery.pending'))
->badge()
->color(fn (ImageAttachment $record) => $record->media?->width ? 'gray' : 'warning')
->toggleable(),
])
->headerActions([
CreateAction::make()
->label(__('panel.gallery.actions.add'))
// New images go at the end rather than jumping to the top.
->mutateDataUsing(function (array $data): array {
$data['position'] = (int) $this->getOwnerRecord()->images()->max('position') + 1;
return $data;
}),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
])
->toolbarActions([
DeleteBulkAction::make(),
])
->emptyStateHeading(__('panel.gallery.empty.heading'))
->emptyStateDescription(__('panel.gallery.empty.description'))
->emptyStateIcon('heroicon-o-photo');
}
}

View File

@@ -0,0 +1,136 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\RelationManagers;
use App\Enums\GitProvider;
use App\Models\Repository;
use App\Services\Git\GitException;
use App\Services\Git\GitManager;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Notifications\Notification;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
/**
* Connect repositories from inside a project, which is where the person adding
* them is already working.
*
* A newly attached repository is synced immediately so its stats appear at
* once, rather than staying blank until the hourly schedule runs.
*/
class RepositoriesRelationManager extends RelationManager
{
protected static string $relationship = 'repositories';
public static function getTitle(Model $ownerRecord, string $pageClass): string
{
return __('panel.repositories.plural');
}
public function form(Schema $schema): Schema
{
return $schema->components([
Select::make('provider')
->label(__('panel.repositories.fields.provider'))
->options(GitProvider::class)
->default(GitProvider::default())
->required()
->disableOptionWhen(fn (string $value) => ! GitProvider::from($value)->isSupported()),
TextInput::make('full_name')
->label(__('panel.repositories.fields.full_name'))
->placeholder('colectivo/mi-proyecto')
->helperText(__('panel.repositories.fields.full_name_hint'))
->required()
->maxLength(255),
Toggle::make('is_primary')
->label(__('panel.repositories.fields.is_primary')),
Toggle::make('show_publicly')
->label(__('panel.repositories.fields.show_publicly'))
->default(true),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('full_name')
->columns([
TextColumn::make('full_name')
->label(__('panel.repositories.fields.full_name'))
->url(fn (Repository $r) => $r->html_url, shouldOpenInNewTab: true),
TextColumn::make('primary_language')
->label(__('panel.repositories.fields.language'))
->badge()
->placeholder('—'),
TextColumn::make('stars')->label('★')->badge()->color('warning'),
TextColumn::make('good_first_issues_count')
->label(__('panel.repositories.fields.good_first_issues'))
->counts('goodFirstIssues')
->badge(),
TextColumn::make('pushed_at')
->label(__('panel.repositories.fields.pushed_at'))
->since()
->color(fn (Repository $r) => $r->isDormant() ? 'danger' : null)
->placeholder('—'),
])
->headerActions([
CreateAction::make()
// Sync straight away so the stats are not blank until the
// next scheduled run.
->after(function (Repository $record, GitManager $git): void {
try {
$git->sync($record);
} catch (GitException $e) {
Notification::make()
->warning()
->title(__('panel.repositories.notifications.sync_failed'))
->body($e->getMessage())
->send();
}
}),
])
->recordActions([
Action::make('sync')
->label(__('panel.repositories.actions.sync'))
->icon('heroicon-o-arrow-path')
->color('gray')
->visible(fn () => Auth::user()?->can('repositories.sync'))
->action(function (Repository $record, GitManager $git): void {
try {
$git->sync($record);
Notification::make()
->success()
->title(__('panel.repositories.notifications.synced'))
->send();
} catch (GitException $e) {
Notification::make()
->danger()
->title(__('panel.repositories.notifications.sync_failed'))
->body($e->getMessage())
->send();
}
}),
DeleteAction::make(),
]);
}
}

View File

@@ -0,0 +1,226 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\Schemas;
use App\Enums\ProjectStatus;
use App\Filament\Resources\Projects\ProjectResource;
use App\Filament\Support\TranslatableTabs;
use App\Models\Project;
use App\Rules\UniqueTranslatedSlug;
use App\Support\DuplicateTitles;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
class ProjectForm
{
public static function configure(Schema $schema): Schema
{
return $schema->components([
Section::make(__('panel.projects.sections.content'))
->schema([
TranslatableTabs::make(fn (string $locale, bool $isDefault) => [
TextInput::make("title.{$locale}")
->label(__('panel.projects.fields.title'))
->required($isDefault)
->maxLength(255)
->columnSpanFull()
->live(onBlur: true)
->afterStateUpdated(function (?string $state, ?Model $record, callable $get, callable $set) use ($locale, $isDefault) {
if (blank($get("slug.{$locale}"))) {
$set("slug.{$locale}", Str::slug((string) $state));
}
if ($isDefault) {
DuplicateTitles::warnIfSimilar(
Project::class,
ProjectResource::class,
$state,
$locale,
$record?->getKey(),
);
}
}),
TextInput::make("slug.{$locale}")
->label(__('panel.projects.fields.slug'))
->required($isDefault)
->maxLength(255)
->columnSpanFull()
->rules(fn ($record) => [new UniqueTranslatedSlug(Project::class, $record?->id)]),
Textarea::make("tagline.{$locale}")
->label(__('panel.projects.fields.tagline'))
->rows(2)
->maxLength(300)
->columnSpanFull(),
RichEditor::make("description.{$locale}")
->label(__('panel.projects.fields.description'))
->columnSpanFull(),
]),
]),
// The part that makes a project worth reading rather than just
// looking at. Collapsed by default so it never blocks publishing.
Section::make(__('panel.projects.sections.writeup'))
->description(__('panel.projects.sections.writeup_hint'))
->collapsed()
->schema([
TranslatableTabs::make(fn (string $locale) => [
RichEditor::make("decisions.{$locale}")
->label(__('panel.projects.fields.decisions'))
->helperText(__('panel.projects.fields.decisions_hint'))
->columnSpanFull(),
RichEditor::make("postmortem.{$locale}")
->label(__('panel.projects.fields.postmortem'))
->helperText(__('panel.projects.fields.postmortem_hint'))
->columnSpanFull(),
], label: __('panel.projects.sections.writeup')),
]),
Section::make(__('panel.projects.sections.details'))
->columns(2)
->schema([
Select::make('status')
->label(__('panel.projects.fields.status'))
->options(ProjectStatus::class)
->default(ProjectStatus::Idea)
->required(),
DateTimePicker::make('published_at')
->label(__('panel.projects.fields.published_at'))
->seconds(false)
->helperText(__('panel.projects.fields.published_at_hint'))
->disabled(fn () => Auth::user()?->cannot('projects.publish'))
->dehydrated(),
DateTimePicker::make('unpublish_at')
->label(__('panel.projects.fields.unpublish_at'))
->helperText(__('panel.projects.fields.unpublish_at_hint'))
->seconds(false)
->after('published_at')
->disabled(fn () => Auth::user()?->cannot('projects.publish'))
->dehydrated(),
Select::make('technologies')
->label(__('panel.projects.fields.technologies'))
->relationship('technologies', 'name')
->multiple()
->preload()
->searchable()
->columnSpanFull(),
Select::make('lead_member_id')
->label(__('panel.projects.fields.lead'))
->relationship('lead', 'name')
->searchable()
->preload(),
Select::make('members')
->label(__('panel.projects.fields.members'))
->relationship('members', 'name')
->multiple()
->preload()
->searchable(),
// Was two free-text fields, which made the same
// association two entities and left the logo nowhere to
// live. New ones can still be added without leaving the
// project.
Select::make('client_id')
->label(__('panel.projects.fields.client'))
->helperText(__('panel.projects.fields.client_hint'))
->relationship('client', 'name')
->searchable()
->preload()
->createOptionForm([
TextInput::make('name')
->label(__('panel.clients.fields.name'))
->required()
->maxLength(255),
TextInput::make('slug')
->label(__('panel.clients.fields.slug'))
->required()
->maxLength(255)
->rules(['unique:clients,slug']),
TextInput::make('url')
->label(__('panel.clients.fields.url'))
->url()
->maxLength(2048),
]),
Select::make('services')
->label(__('panel.projects.fields.services'))
// The order is given explicitly because Filament
// would otherwise sort a `select distinct` by a JSON
// path, and Postgres refuses an ORDER BY expression
// that is not in the select list.
->relationship(
name: 'services',
titleAttribute: 'title->'.config('locales.default'),
modifyQueryUsing: fn (Builder $query) => $query->orderBy('position'),
)
->multiple()
->preload()
->searchable(),
TextInput::make('demo_url')
->label(__('panel.projects.fields.demo_url'))
->url()
->maxLength(2048),
FileUpload::make('cover_image')
->label(__('panel.projects.fields.cover_image'))
->image()
// Explicit: the default disk is private, and the
// frontend runs on another host.
->disk(config('media.disk'))
->directory('projects')
->imageEditor()
->live(),
TranslatableTabs::make(fn (string $locale) => [
TextInput::make("cover_image_alt.{$locale}")
->label(__('panel.projects.fields.cover_image_alt'))
->helperText(__('panel.projects.fields.cover_image_alt_hint'))
->maxLength(255)
->columnSpanFull(),
])
->visible(fn (callable $get) => filled($get('cover_image')))
->columnSpanFull(),
DatePicker::make('started_at')
->label(__('panel.projects.fields.started_at')),
DatePicker::make('ended_at')
->label(__('panel.projects.fields.ended_at')),
Toggle::make('is_featured')
->label(__('panel.projects.fields.is_featured')),
// Drives the "we need help" listings on the public site,
// which is the main thing the site is trying to achieve.
Toggle::make('needs_help')
->label(__('panel.projects.fields.needs_help'))
->helperText(__('panel.projects.fields.needs_help_hint')),
]),
]);
}
}

View File

@@ -0,0 +1,254 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Projects\Tables;
use App\Enums\ProjectStatus;
use App\Filament\Support\PreviewAction;
use App\Filament\Support\ReviewActions;
use App\Filament\Support\ReviewStatusColumn;
use App\Filament\Support\TranslationStatusColumn;
use App\Filament\Support\ViewsColumn;
use App\Models\Project;
use App\Support\TranslationFreshness;
use Filament\Actions\Action;
use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Actions\ForceDeleteBulkAction;
use Filament\Actions\ReplicateAction;
use Filament\Actions\RestoreBulkAction;
use Filament\Notifications\Notification;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Auth;
class ProjectsTable
{
public static function configure(Table $table): Table
{
$locale = app()->getLocale();
return $table
// One grouped query for the whole page of rows, so the reading
// figures cost the listing nothing per row.
->modifyQueryUsing(fn (Builder $query) => $query->withRecentViews())
->defaultSort('position')
->reorderable('position')
->columns([
TextColumn::make('title')
->label(__('panel.projects.fields.title'))
->weight('medium')
->description(fn (Project $record) => $record->getTranslation('tagline', $locale, false) ?: null)
->wrap()
->searchable(query: fn (Builder $q, string $search) => $q
->where("title->{$locale}", 'like', "%{$search}%"))
->sortable(query: fn (Builder $q, string $direction) => $q
->orderBy("title->{$locale}", $direction)),
TranslationStatusColumn::make('translations')
->label(__('panel.pages.fields.translations'))
->trackedAttribute('title'),
TextColumn::make('status')
->label(__('panel.projects.fields.status'))
->badge()
->sortable(),
TextColumn::make('technologies.name')
->label(__('panel.projects.fields.technologies'))
->badge()
->color('gray')
->limitList(3)
->expandableLimitedList()
->toggleable(),
// Live repository activity, so the panel shows the same signs
// of life the public site does.
TextColumn::make('repositories_sum_stars')
->label('★')
->sum('repositories', 'stars')
->badge()
->color('warning')
->toggleable(),
IconColumn::make('needs_help')
->label(__('panel.projects.fields.needs_help'))
->boolean()
->trueIcon('heroicon-o-hand-raised')
->falseIcon('heroicon-o-minus-small')
->trueColor('warning')
->falseColor('gray')
->sortable(),
IconColumn::make('is_featured')
->label(__('panel.projects.fields.is_featured'))
->boolean()
->toggleable(),
// A project's status is its lifecycle, not its visibility —
// those are different questions, so the window gets its own
// column rather than overwriting the answer to the first.
ViewsColumn::make('recent_views')
->label(__('panel.views.column'))
->tooltip(__('panel.views.column_hint')),
ReviewStatusColumn::make('review')
->label(__('panel.reviews.column')),
TextColumn::make('published_at')
->label(__('panel.projects.fields.published_at'))
->badge()
->formatStateUsing(fn (?string $state, Project $record) => match (true) {
$record->hasExpired() => __('panel.publishing.expired'),
$record->isScheduled() => __('panel.publishing.scheduled'),
blank($state) => __('panel.publishing.unpublished'),
default => __('panel.publishing.live'),
})
->color(fn (?string $state, Project $record) => match (true) {
$record->hasExpired() => 'gray',
$record->isScheduled() => 'info',
blank($state) => 'gray',
default => 'success',
})
->description(fn (Project $record) => match (true) {
$record->hasExpired() => __('panel.publishing.expired_at', ['time' => $record->unpublish_at->isoFormat('LLL')]),
$record->isScheduled() => $record->published_at->diffForHumans(),
$record->expiresSoon() => __('panel.publishing.expires_in', ['time' => $record->unpublish_at->diffForHumans()]),
default => $record->published_at?->isoFormat('LL'),
})
->sortable()
->placeholder('—'),
])
->filters([
// The reviewer's own queue. Unaddressed requests are in it
// too: a review nobody was named for is everybody's.
Filter::make('awaiting_review')
->label(__('panel.reviews.filters.mine'))
->query(fn (Builder $query) => Auth::user()
? $query->awaitingReviewBy(Auth::user())
: $query->awaitingReview()),
Filter::make('scheduled')
->label(__('panel.publishing.scheduled'))
->query(fn (Builder $query) => $query->scheduled()),
Filter::make('expired')
->label(__('panel.publishing.expired'))
->query(fn (Builder $query) => $query->expired()),
SelectFilter::make('status')
->label(__('panel.projects.fields.status'))
->options(ProjectStatus::options())
->multiple(),
SelectFilter::make('technologies')
->label(__('panel.projects.fields.technologies'))
->relationship('technologies', 'name')
->multiple()
->preload(),
TernaryFilter::make('needs_help')
->label(__('panel.projects.fields.needs_help')),
// Published and, as far as anybody can tell, read by nobody.
Filter::make('unread')
->label(__('panel.views.filters.unread'))
->query(fn (Builder $query) => $query
->published()
->whereDoesntHave('views', fn (Builder $views) => $views->since(30))),
// Translated and left behind by the original. Worked out
// from the change history rather than a column, so it is
// resolved here and handed to the query as a list.
Filter::make('stale_translation')
->label(__('panel.translations.filters.stale'))
->query(fn (Builder $query) => $query->whereIn(
'id',
TranslationFreshness::staleIds($query->getModel()::query()),
)),
Filter::make('unpublished')
->label(__('panel.projects.filters.unpublished'))
->query(fn (Builder $q) => $q->whereNull('published_at')),
TrashedFilter::make(),
])
->recordActions([
ReviewActions::request(),
ReviewActions::returnForChanges(),
Action::make('publish')
->label(__('panel.projects.actions.publish'))
->icon('heroicon-o-globe-alt')
->color('success')
->requiresConfirmation()
->visible(fn (Project $record) => $record->published_at === null
&& Auth::user()?->can('publish', $record))
->action(fn (Project $record) => $record->update(['published_at' => now()])),
// A near-copy is a real workflow: the third similar service,
// next year's call. The slug is cleared because two records
// cannot answer at the same URL.
ReplicateAction::make()
->label(__('panel.actions.duplicate'))
->icon('heroicon-o-document-duplicate')
->excludeAttributes(['slug', 'published_at', 'unpublish_at'])
->modalHeading(__('panel.actions.duplicate_heading'))
->successNotificationTitle(__('panel.actions.duplicated')),
PreviewAction::for('project'),
EditAction::make(),
DeleteAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
ReviewActions::requestBulk(Project::class),
BulkAction::make('publish')
->label(__('panel.projects.actions.publish'))
->icon('heroicon-o-globe-alt')
->color('success')
->requiresConfirmation()
->visible(fn () => Auth::user()?->can('projects.publish') ?? false)
->deselectRecordsAfterCompletion()
->action(function (Collection $records): void {
$published = 0;
// One at a time: publishing fires the revision
// entry and closes any pending review, and a mass
// update would skip both without a sound.
foreach ($records as $record) {
if ($record->published_at !== null) {
continue;
}
$record->update(['published_at' => now()]);
$published++;
}
Notification::make()
->title(trans_choice('panel.publishing.published_count', $published, ['count' => $published]))
->success()
->send();
}),
DeleteBulkAction::make(),
ForceDeleteBulkAction::make(),
RestoreBulkAction::make(),
]),
]);
}
}