From 44832225eb042547a3b740c91d22e929ab983f64 Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Fri, 17 Jan 2025 12:46:07 -0800 Subject: [PATCH] [TM-1624] Provide a parent name attribute on reports. --- app/Models/V2/Nurseries/NurseryReport.php | 5 +++++ app/Models/V2/Projects/ProjectReport.php | 5 +++++ app/Models/V2/Sites/SiteReport.php | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/app/Models/V2/Nurseries/NurseryReport.php b/app/Models/V2/Nurseries/NurseryReport.php index 99405d985..f8f3cea27 100644 --- a/app/Models/V2/Nurseries/NurseryReport.php +++ b/app/Models/V2/Nurseries/NurseryReport.php @@ -287,4 +287,9 @@ public function getAuditableNameAttribute(): string { return $this->title ?? ''; } + + public function getParentNameAttribute(): string + { + return $this->nursery?->name ?? ''; + } } diff --git a/app/Models/V2/Projects/ProjectReport.php b/app/Models/V2/Projects/ProjectReport.php index 2ed0c631c..3083fbf60 100644 --- a/app/Models/V2/Projects/ProjectReport.php +++ b/app/Models/V2/Projects/ProjectReport.php @@ -531,4 +531,9 @@ public function scopeApproved($query) { return $query->where('status', ReportStatusStateMachine::APPROVED); } + + public function getParentNameAttribute(): string + { + return $this->project?->name ?? ''; + } } diff --git a/app/Models/V2/Sites/SiteReport.php b/app/Models/V2/Sites/SiteReport.php index 97f0a78ce..40b0c01b4 100644 --- a/app/Models/V2/Sites/SiteReport.php +++ b/app/Models/V2/Sites/SiteReport.php @@ -402,6 +402,11 @@ public function getAuditableNameAttribute(): string return $this->title ?? ''; } + public function getParentNameAttribute(): string + { + return $this->site?->name ?? ''; + } + public static function search($query) { return self::select('v2_site_reports.*')