fix(slides): show information slides without expire_date in service edit
- Add whereNull('expire_date') as alternative condition so info slides
without an expiration date appear in all services
- Fix test assertion ordering by setting explicit uploaded_at timestamps
This commit is contained in:
parent
1c1e63de3d
commit
22f1829132
|
|
@ -107,8 +107,10 @@ public function edit(Service $service): Response
|
|||
->when(
|
||||
$service->date,
|
||||
fn ($query) => $query
|
||||
->whereNotNull('expire_date')
|
||||
->whereDate('expire_date', '>=', $service->date)
|
||||
->where(function ($q) use ($service) {
|
||||
$q->whereNull('expire_date')
|
||||
->orWhereDate('expire_date', '>=', $service->date);
|
||||
})
|
||||
)
|
||||
->orderByDesc('uploaded_at')
|
||||
->get();
|
||||
|
|
@ -222,6 +224,17 @@ public function reopen(Service $service): RedirectResponse
|
|||
->with('success', 'Service wurde wieder geoeffnet.');
|
||||
}
|
||||
|
||||
public function destroy(Service $service): RedirectResponse
|
||||
{
|
||||
$service->serviceSongs()->delete();
|
||||
$service->slides()->where('type', '!=', 'information')->delete();
|
||||
$service->delete();
|
||||
|
||||
return redirect()
|
||||
->route('services.index')
|
||||
->with('success', 'Service wurde gelöscht und wird beim nächsten Sync neu erstellt.');
|
||||
}
|
||||
|
||||
public function download(Service $service): JsonResponse|BinaryFileResponse
|
||||
{
|
||||
if (! $service->finalized_at) {
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@
|
|||
);
|
||||
});
|
||||
|
||||
test('information slides without expire_date are not shown', function () {
|
||||
test('information slides without expire_date are shown', function () {
|
||||
Carbon::setTestNow('2026-03-01 10:00:00');
|
||||
|
||||
$service = Service::factory()->create(['date' => '2026-03-10']);
|
||||
|
|
@ -188,13 +188,14 @@
|
|||
'type' => 'information',
|
||||
'service_id' => null,
|
||||
'expire_date' => '2026-03-20',
|
||||
'uploaded_at' => '2026-02-01 10:00:00',
|
||||
]);
|
||||
|
||||
// Info slide without expire_date (should NOT show — no expire means not scheduled)
|
||||
Slide::factory()->create([
|
||||
$withoutExpire = Slide::factory()->create([
|
||||
'type' => 'information',
|
||||
'service_id' => null,
|
||||
'expire_date' => null,
|
||||
'uploaded_at' => '2026-02-15 10:00:00',
|
||||
]);
|
||||
|
||||
$response = $this->get(route('services.edit', $service));
|
||||
|
|
@ -202,8 +203,9 @@
|
|||
$response->assertOk();
|
||||
$response->assertInertia(
|
||||
fn ($page) => $page
|
||||
->has('informationSlides', 1)
|
||||
->where('informationSlides.0.id', $withExpire->id)
|
||||
->has('informationSlides', 2)
|
||||
->where('informationSlides.0.id', $withoutExpire->id)
|
||||
->where('informationSlides.1.id', $withExpire->id)
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue