From 541bff27f99994fd15bc9a2eb0d3fd598a53cc17 Mon Sep 17 00:00:00 2001 From: Limber Mamani Date: Thu, 19 Dec 2024 17:21:54 -0400 Subject: [PATCH] [TM-1562] add count to replanting collection --- app/Http/Resources/V2/SiteReports/SiteReportResource.php | 1 + app/Models/V2/Sites/SiteReport.php | 5 +++++ app/Models/V2/TreeSpecies/TreeSpecies.php | 2 ++ 3 files changed, 8 insertions(+) diff --git a/app/Http/Resources/V2/SiteReports/SiteReportResource.php b/app/Http/Resources/V2/SiteReports/SiteReportResource.php index aa28b7c5..9e865c21 100644 --- a/app/Http/Resources/V2/SiteReports/SiteReportResource.php +++ b/app/Http/Resources/V2/SiteReports/SiteReportResource.php @@ -65,6 +65,7 @@ public function toArray($request) 'created_by' => $this->handleCreatedBy(), 'regeneration_description' => $this->regeneration_description, 'total_non_tree_species_planted_count' => $this->total_non_tree_species_planted_count, + 'total_tree_replanting_count' => $this->total_tree_replanting_count, 'pct_survival_to_date' => $this->pct_survival_to_date, 'survival_calculation' => $this->survival_calculation, diff --git a/app/Models/V2/Sites/SiteReport.php b/app/Models/V2/Sites/SiteReport.php index bfa5eb83..97f0a78c 100644 --- a/app/Models/V2/Sites/SiteReport.php +++ b/app/Models/V2/Sites/SiteReport.php @@ -307,6 +307,11 @@ public function getTotalNonTreeSpeciesPlantedCountAttribute(): int return $this->nonTreeSpecies()->visible()->sum('amount'); } + public function getTotalTreeReplantingCountAttribute(): int + { + return $this->replantingTreeSpecies()->visible()->sum('amount'); + } + public function getTotalSeedsPlantedCountAttribute(): int { return $this->seedings()->visible()->sum('amount'); diff --git a/app/Models/V2/TreeSpecies/TreeSpecies.php b/app/Models/V2/TreeSpecies/TreeSpecies.php index ff4dc072..b5edc88a 100644 --- a/app/Models/V2/TreeSpecies/TreeSpecies.php +++ b/app/Models/V2/TreeSpecies/TreeSpecies.php @@ -44,6 +44,7 @@ class TreeSpecies extends Model implements EntityRelationModel public const COLLECTION_DIRECT_SEEDING = 'direct-seeding'; public const COLLECTION_PLANTED = 'tree-planted'; public const COLLECTION_NON_TREE = 'non-tree'; + public const COLLECTION_REPLANTING = 'replanting'; public const COLLECTION_NURSERY = 'nursery-seedling'; public const COLLECTION_HISTORICAL = 'historical-tree-species'; @@ -51,6 +52,7 @@ class TreeSpecies extends Model implements EntityRelationModel self::COLLECTION_DIRECT_SEEDING => 'Direct Seeding', self::COLLECTION_PLANTED => 'Planted', self::COLLECTION_NON_TREE => 'Non Tree', + self::COLLECTION_REPLANTING => 'Replanting', self::COLLECTION_NURSERY => 'Nursery Seedling', self::COLLECTION_HISTORICAL => 'Historical Tree Species', ];