update([ 'activity_id' => $activity->id, 'subactivity_id' => $subactivity ? $subactivity->id : null, 'promised_at' => $promisedAt, ]); return $membership; } /** * @return array> */ public function rules(): array { $subactivityRule = request()->activity_id ? ['nullable', Rule::exists('activity_subactivity', 'subactivity_id')->where('activity_id', request()->activity_id)] : ['nullable']; return [ 'activity_id' => ['bail', 'required', 'exists:activities,id'], 'subactivity_id' => $subactivityRule, 'promised_at' => ['nullable', 'date'], ]; } /** * @return array */ public function getValidationAttributes(): array { return [ 'activity_id' => 'Tätigkeit', 'subactivity_id' => 'Untertätigkeit', ]; } public function asController(Membership $membership, ActionRequest $request): JsonResponse { $this->handle( $membership, Activity::find($request->activity_id), $request->subactivity_id ? Subactivity::find($request->subactivity_id) : null, $request->promised_at ? Carbon::parse($request->promised_at) : null, ); ResyncAction::dispatch(); return response()->json([]); } }