Add approve-and-live action for Live Show
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-05 14:16:27 +01:00
parent 148c075d58
commit 99186e8e2f
7 changed files with 172 additions and 10 deletions

View File

@@ -30,7 +30,6 @@ class LiveShowPhotoController extends Controller
$query = Photo::query()
->where('event_id', $event->id)
->where('status', 'approved')
->with('event')
->withCount('likes');
@@ -89,6 +88,58 @@ class LiveShowPhotoController extends Controller
]);
}
public function approveAndLive(LiveShowApproveRequest $request, string $eventSlug, Photo $photo): JsonResponse
{
$tenantId = $request->attributes->get('tenant_id');
$event = Event::where('slug', $eventSlug)
->where('tenant_id', $tenantId)
->firstOrFail();
if ($photo->event_id !== $event->id) {
return ApiError::response(
'photo_not_found',
'Photo not found',
'The specified photo could not be located for this event.',
Response::HTTP_NOT_FOUND,
['photo_id' => $photo->id]
);
}
if (in_array($photo->status, ['rejected', 'hidden'], true)) {
return ApiError::response(
'photo_not_eligible',
'Photo not eligible',
'Rejected or hidden photos cannot be approved for Live Show.',
Response::HTTP_UNPROCESSABLE_ENTITY,
['photo_id' => $photo->id]
);
}
if ($photo->status !== 'approved') {
$photo->forceFill([
'status' => 'approved',
'moderated_at' => now(),
'moderated_by' => $request->user()?->id,
'moderation_notes' => null,
])->save();
}
$photo->approveForLiveShow($request->user());
if ($request->filled('priority')) {
$photo->forceFill([
'live_priority' => $request->integer('priority'),
])->save();
}
$photo->refresh()->load('event')->loadCount('likes');
return response()->json([
'message' => 'Photo approved and added to Live Show',
'data' => new PhotoResource($photo),
]);
}
public function reject(LiveShowRejectRequest $request, string $eventSlug, Photo $photo): JsonResponse
{
$tenantId = $request->attributes->get('tenant_id');