whereKey($occupation->id)->lockForUpdate()->firstOrFail(); if (! in_array($record->source, ['channel', 'email'], true) || $record->is_representation) { throw ValidationException::withMessages(['occupation_kind' => 'Nur eigenständige Portalereignisse können hier eingeordnet werden.']); } if ($originId !== null && ! Channel::query()->where('property_id', $record->property_id)->whereKey($originId)->exists()) { throw ValidationException::withMessages(['origin_channel_id' => 'Der Ursprungskanal muss zur selben Wohnung gehören.']); } $record->forceFill(['occupation_kind' => $kind, 'origin_channel_id' => $originId])->save(); }); } }