user(); if ($event->status === EventStatus::Cancelled) { abort(403); } if (!$event->type->hasTimekeepers()) { abort(403); } if (!$user->canAccessAdminPanel()) { if ($event->status === EventStatus::Draft) { abort(403); } if (!$user->accessibleTeamIds()->contains($event->team_id)) { abort(403); } } $request->validate([ 'status' => 'required|in:yes,no,unknown', ]); $existing = EventTimekeeper::where('event_id', $event->id)->where('user_id', auth()->id())->first(); $oldStatus = $existing?->status?->value ?? 'unknown'; $timekeeper = EventTimekeeper::where('event_id', $event->id)->where('user_id', auth()->id())->first(); if (!$timekeeper) { $timekeeper = new EventTimekeeper(['event_id' => $event->id]); $timekeeper->user_id = auth()->id(); } $timekeeper->status = CateringStatus::from($request->status); $timekeeper->save(); ActivityLog::logWithChanges('status_changed', __('admin.log_timekeeper_changed', ['event' => $event->title, 'status' => $request->status]), 'Event', $event->id, ['status' => $oldStatus, 'user_id' => auth()->id(), 'source' => 'timekeeper'], ['status' => $request->status, 'user_id' => auth()->id(), 'source' => 'timekeeper']); return redirect(route('events.show', $event) . '#timekeeper'); } }