registrationPeriodService->isOpen($election)) { return; } if (blank($note)) { throw ValidationException::withMessages([ 'note' => 'Catatan wajib diisi untuk perubahan selepas tempoh pendaftaran ditutup.', ]); } } public function recordIfClosed(Election $election, Model $noteable, User $actor, ?string $note, string $type): ?SystemNote { if ($this->registrationPeriodService->isOpen($election) || blank($note)) { return null; } return SystemNote::query()->create([ 'election_id' => $election->id, 'noteable_type' => $noteable::class, 'noteable_id' => $noteable->getKey(), 'note_type' => $type, 'note' => $note, 'created_by_user_id' => $actor->id, ]); } }