T14: Service Edit Page Layout + Routing
- ServiceController::edit() with eager-loaded relationships
- Services/Edit.vue with 4 collapsible accordion blocks
- Route: GET /services/{service}/edit
- Information slides query: global + service-specific with expire_date filtering
- Tests: 2 new (edit page render + auth guard)
T15: Information Block (Slides + Expire Dates)
- InformationBlock.vue with dynamic expire_date filtering
- Shows slides where type='information' AND expire_date >= service.date
- Global visibility across services (not service-specific)
- SlideUploader with showExpireDate=true
- SlideGrid with prominent expire date + inline editing
- Badge showing slide count + 'expiring soon' warning (within 3 days)
- Tests: 7 new (105 assertions)
T16: Moderation Block (Service-Specific)
- ModerationBlock.vue (service-specific slides)
- Filters: type='moderation' AND service_id = current_service
- No expire date field (unlike Information block)
- Service isolation (slides from Service A don't appear in Service B)
- Tests: 5 new (14 assertions)
T17: Sermon Block (Service-Specific)
- SermonBlock.vue (identical to Moderation but type='sermon')
- Service-specific slides, no expire date
- Tests: 5 new (14 assertions)
T18: Songs Block (Matching + Arrangement + Translation)
- SongsBlock.vue with conditional UI (unmatched vs matched states)
- Unmatched: 'Erstellung anfragen' button + searchable select for manual assign
- Matched: ArrangementConfigurator + translation checkbox + preview/download buttons
- ServiceSongController::update() for use_translation and song_arrangement_id
- ArrangementConfigurator emits 'arrangement-selected' for auto-save
- ServiceController::edit() provides songsCatalog for matching search
- Tests: 2 new (45 assertions)
T19: Song PDF (INCOMPLETE - timeout)
- SongPdfController.php created (partial)
- resources/views/pdf/song.blade.php created (partial)
- SongPreviewModal.vue MISSING
- Tests MISSING
- Will be completed in next commit
All tests passing: 124/124 (703 assertions)
Build: ✓ Vite production build successful
German UI: All user-facing text in German with 'Du' form
Dependencies: barryvdh/laravel-dompdf added for PDF generation
104 lines
3.1 KiB
PHP
104 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\ServiceSong;
|
|
use App\Models\Song;
|
|
use App\Services\SongMatchingService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ServiceSongController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly SongMatchingService $songMatchingService,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Manuell einen Song aus der DB einem ServiceSong zuordnen.
|
|
*/
|
|
public function assignSong(int $serviceSongId, Request $request): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'song_id' => ['required', 'integer', 'exists:songs,id'],
|
|
]);
|
|
|
|
$serviceSong = ServiceSong::findOrFail($serviceSongId);
|
|
$song = Song::findOrFail($validated['song_id']);
|
|
|
|
$this->songMatchingService->manualAssign($serviceSong, $song);
|
|
|
|
return response()->json([
|
|
'message' => 'Song erfolgreich zugeordnet',
|
|
'service_song' => $serviceSong->fresh(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* E-Mail-Anfrage für fehlenden Song senden.
|
|
*/
|
|
public function requestSong(int $serviceSongId): JsonResponse
|
|
{
|
|
$serviceSong = ServiceSong::findOrFail($serviceSongId);
|
|
|
|
$this->songMatchingService->requestCreation($serviceSong);
|
|
|
|
return response()->json([
|
|
'message' => 'Anfrage wurde gesendet',
|
|
'service_song' => $serviceSong->fresh(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Song-Zuordnung entfernen.
|
|
*/
|
|
public function unassign(int $serviceSongId): JsonResponse
|
|
{
|
|
$serviceSong = ServiceSong::findOrFail($serviceSongId);
|
|
|
|
$this->songMatchingService->unassign($serviceSong);
|
|
|
|
return response()->json([
|
|
'message' => 'Zuordnung entfernt',
|
|
'service_song' => $serviceSong->fresh(),
|
|
]);
|
|
}
|
|
|
|
public function update(int $serviceSongId, Request $request): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'song_arrangement_id' => ['nullable', 'integer', 'exists:song_arrangements,id'],
|
|
'use_translation' => ['sometimes', 'boolean'],
|
|
]);
|
|
|
|
$serviceSong = ServiceSong::with('song')->findOrFail($serviceSongId);
|
|
|
|
if (array_key_exists('song_arrangement_id', $validated) && $validated['song_arrangement_id'] !== null) {
|
|
if ($serviceSong->song_id === null || $serviceSong->song === null) {
|
|
return response()->json([
|
|
'message' => 'Arrangement kann ohne zugeordneten Song nicht gespeichert werden.',
|
|
], 422);
|
|
}
|
|
|
|
$isValidArrangement = $serviceSong->song
|
|
->arrangements()
|
|
->whereKey($validated['song_arrangement_id'])
|
|
->exists();
|
|
|
|
if (! $isValidArrangement) {
|
|
return response()->json([
|
|
'message' => 'Das Arrangement gehoert nicht zu diesem Song.',
|
|
], 422);
|
|
}
|
|
}
|
|
|
|
$serviceSong->update($validated);
|
|
|
|
return response()->json([
|
|
'message' => 'Service-Song wurde aktualisiert.',
|
|
'service_song' => $serviceSong->fresh(),
|
|
]);
|
|
}
|
|
}
|