From 47c1cac5f5d604efb96b54a2d88a57687f69aa59 Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Fri, 10 Jul 2026 17:11:38 +0000 Subject: [PATCH] PM-Liste: Hinweis auf laufende Boost-Platzierung unter dem Status Badge "Boost bis TT.MM.JJJJ" in der Status-Spalte; Boost-Enden der Seite in einer Query aggregiert statt isBoosted() je Zeile. Co-Authored-By: Claude Fable 5 --- .../customer/press-releases/index.blade.php | 20 ++++++++++++ tests/Feature/PressReleaseShowAddonsTest.php | 31 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/resources/views/livewire/customer/press-releases/index.blade.php b/resources/views/livewire/customer/press-releases/index.blade.php index 88689e29..9dfa9917 100644 --- a/resources/views/livewire/customer/press-releases/index.blade.php +++ b/resources/views/livewire/customer/press-releases/index.blade.php @@ -2,6 +2,7 @@ use App\Enums\Portal; use App\Enums\PressReleaseStatus; +use App\Models\Boost; use App\Models\PressRelease; use App\Services\Customer\CustomerCompanyContext; use App\Services\PressRelease\AiDeclarationRequiredException; @@ -150,8 +151,19 @@ new #[Layout('components.layouts.app'), Title('Meine Pressemitteilungen')] class $prs = PressRelease::accessiblePageFor($user, $applyListFilters, $this->sortBy, $this->sortDir); + // Laufende Boosts der Seite in einer Query (statt isBoosted() je + // Zeile): [press_release_id => spätestes ends_at]. + $boostEndsById = Boost::query() + ->active() + ->whereIn('press_release_id', collect($prs->items())->pluck('id')) + ->selectRaw('press_release_id, max(ends_at) as ends_at') + ->groupBy('press_release_id') + ->pluck('ends_at', 'press_release_id') + ->map(fn ($endsAt) => \Illuminate\Support\Carbon::parse($endsAt)); + return [ 'pressReleases' => $prs, + 'boostEndsById' => $boostEndsById, 'statusOptions' => PressReleaseStatus::cases(), 'portalOptions' => Portal::cases(), 'selectedCompany' => $context->selectedCompany(auth()->user()), @@ -472,6 +484,14 @@ new #[Layout('components.layouts.app'), Title('Meine Pressemitteilungen')] class :has-title-image="$pr->images_count > 0" /> @endif + @if ($boostEndsAt = $boostEndsById->get($pr->id)) + {{-- Laufende Boost-Platzierung (Add-on) direkt unter dem Status. --}} +
+ + {{ __('Boost bis :date', ['date' => $boostEndsAt->format('d.m.Y')]) }} + +
+ @endif diff --git a/tests/Feature/PressReleaseShowAddonsTest.php b/tests/Feature/PressReleaseShowAddonsTest.php index 44b1c109..4525df19 100644 --- a/tests/Feature/PressReleaseShowAddonsTest.php +++ b/tests/Feature/PressReleaseShowAddonsTest.php @@ -1,6 +1,7 @@ fresh()->isBoosted())->toBeFalse(); }); +test('the press release list shows a hint with end date for an active boost', function () { + /** @var TestCase $this */ + ['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner(); + $this->wallet->credit($customer, 40); + + $this->actingAs($customer); + + LivewireVolt::test('customer.press-releases.index') + ->assertDontSee('Boost bis'); + + Boost::factory()->for($pr)->create([ + 'ends_at' => now()->addDays(7)->setTime(9, 0), + ]); + + LivewireVolt::test('customer.press-releases.index') + ->assertSee('Boost bis '.now()->addDays(7)->format('d.m.Y')); +}); + +test('an expired boost shows no hint in the press release list', function () { + /** @var TestCase $this */ + ['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner(); + + $this->actingAs($customer); + + Boost::factory()->for($pr)->expired()->create(); + + LivewireVolt::test('customer.press-releases.index') + ->assertDontSee('Boost bis'); +}); + test('a non-green release cannot be boosted from the detail page', function () { /** @var TestCase $this */ ['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();