model->create($data); } /** * 특정 사용자의 모든 동의 이력을 조회합니다 (최신순). * * @param int $userId 사용자 ID * @return Collection 동의 이력 컬렉션 */ public function getByUser(int $userId): Collection { return $this->model ->where('user_id', $userId) ->orderByDesc('agreed_at') ->get(); } /** * 특정 사용자의 특정 유형 최신 동의 이력을 조회합니다. * * @param int $userId 사용자 ID * @param string $consentType 동의 유형 (ConsentType 값) * @return UserConsent|null 최신 동의 이력 또는 null */ public function getLatestByType(int $userId, string $consentType): ?UserConsent { return $this->model ->where('user_id', $userId) ->where('consent_type', $consentType) ->orderByDesc('agreed_at') ->first(); } }