diff --git a/app/Filament/Dashboard/Resources/CollectionResource.php b/app/Filament/Dashboard/Resources/CollectionResource.php index e013be93..a745e0ee 100644 --- a/app/Filament/Dashboard/Resources/CollectionResource.php +++ b/app/Filament/Dashboard/Resources/CollectionResource.php @@ -75,6 +75,15 @@ public static function table(Table $table): Table return $table ->columns([ Tables\Columns\TextColumn::make('title')->wrap(), + Tables\Columns\TextColumn::make('status') + ->badge() + ->color(fn (string $state): string => match ($state) { + 'DRAFT' => 'info', + 'REVIEW' => 'warning', + 'EMBARGO' => 'warning', + 'PUBLISHED' => 'success', + 'REJECTED' => 'danger', + }), ]) ->filters([ // diff --git a/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php b/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php index 57a22039..4e57a22d 100644 --- a/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php +++ b/app/Filament/Dashboard/Resources/CollectionResource/RelationManagers/EntriesRelationManager.php @@ -166,6 +166,16 @@ public function table(Table $table): Table ->action(function () { Artisan::call('entries:process'); }), + Action::make('publish') + ->hidden(function () { + return $this->ownerRecord->molecules()->where('status', 'DRAFT')->count() < 1; + }) + ->action(function () { + $this->ownerRecord->status = 'PUBLISHED'; + $this->ownerRecord->is_public = true; + $this->ownerRecord->molecules()->where('status', 'DRAFT')->update(['status' => 'APPROVED']); + $this->ownerRecord->save(); + }), // Tables\Actions\CreateAction::make(), ]) ->actions([