diff --git a/app/Http/Controllers/V2/Projects/CreateProjectWithFormController.php b/app/Http/Controllers/V2/Projects/CreateProjectWithFormController.php index 2f3d37c98..ca6495a3a 100644 --- a/app/Http/Controllers/V2/Projects/CreateProjectWithFormController.php +++ b/app/Http/Controllers/V2/Projects/CreateProjectWithFormController.php @@ -96,6 +96,7 @@ public function __invoke(Request $request): EntityWithSchemaResource 'goal_trees_restored_planting' => $projectPitch->goal_trees_restored_planting, 'goal_trees_restored_anr' => $projectPitch->goal_trees_restored_anr, 'goal_trees_restored_direct_seeding' => $projectPitch->goal_trees_restored_direct_seeding, + 'direct_seeding_survival_rate' => $projectPitch->direct_seeding_survival_rate, ]); foreach ($projectPitch->treeSpecies()->get() as $treeSpecies) { diff --git a/app/Http/Resources/V2/Projects/ProjectResource.php b/app/Http/Resources/V2/Projects/ProjectResource.php index 55b4eb861..8d6393c04 100644 --- a/app/Http/Resources/V2/Projects/ProjectResource.php +++ b/app/Http/Resources/V2/Projects/ProjectResource.php @@ -97,6 +97,7 @@ public function toArray($request) 'updated_at' => $this->updated_at, 'trees_restored_ppc' => $this->getTreesGrowingThroughAnr($this->sites) + (($this->trees_planted_count + $this->seeds_planted_count) * ($this->survival_rate / 100)), + 'direct_seeding_survival_rate' => $this->direct_seeding_survival_rate, ]; return $this->appendFilesToResource($data); diff --git a/app/Models/V2/Projects/Project.php b/app/Models/V2/Projects/Project.php index a00ae3af1..beb6fff40 100644 --- a/app/Models/V2/Projects/Project.php +++ b/app/Models/V2/Projects/Project.php @@ -144,6 +144,7 @@ class Project extends Model implements MediaModel, AuditableContract, EntityMode 'goal_trees_restored_anr', 'goal_trees_restored_direct_seeding', 'landscape', + 'direct_seeding_survival_rate' ]; public $fileConfiguration = [ diff --git a/config/wri/linked-fields.php b/config/wri/linked-fields.php index c684d8d89..56c75c231 100644 --- a/config/wri/linked-fields.php +++ b/config/wri/linked-fields.php @@ -262,6 +262,7 @@ 'pro-pit-goal-trees-restored-planting' => ['property' => 'goal_trees_restored_planting', 'label' => 'Trees Restored Goal - Planting', 'input_type' => 'number'], 'pro-pit-goal-trees-restored-anr' => ['property' => 'goal_trees_restored_anr', 'label' => 'Trees Restored Goal - ANR', 'input_type' => 'number'], 'pro-pit-goal-trees-restored-direct-seeding' => ['property' => 'goal_trees_restored_direct_seeding', 'label' => 'Trees Restored Goal - Direct Seeding', 'input_type' => 'number'], + 'pro-pit-direct-seeding-survival-rate' => ['property' => 'direct_seeding_survival_rate', 'label' => 'Direct Seeding Survival Rate', 'input_type' => 'number-percentage'], ], 'file-collections' => [ 'pro-pit-fcol-cover' => ['property' => 'cover', 'label' => 'Cover Image', 'input_type' => 'file', 'multichoice' => false], @@ -343,6 +344,7 @@ 'pro-goal-trees-restored-planting' => ['property' => 'goal_trees_restored_planting', 'label' => 'Trees Restored Goal - Planting', 'input_type' => 'number'], 'pro-goal-trees-restored-anr' => ['property' => 'goal_trees_restored_anr', 'label' => 'Trees Restored Goal - ANR', 'input_type' => 'number'], 'pro-goal-trees-restored-direct-seeding' => ['property' => 'goal_trees_restored_direct_seeding', 'label' => 'Trees Restored Goal - Direct Seeding', 'input_type' => 'number'], + 'pro-direct-seeding-survival-rate' => ['property' => 'direct_seeding_survival_rate', 'label' => 'Direct Seeding Survival Rate', 'input_type' => 'number-percentage'], ], 'file-collections' => [ 'pro-col-media' => ['property' => 'media', 'label' => 'Media', 'input_type' => 'file', 'multichoice' => true], diff --git a/database/migrations/2024_11_19_153800_add_field_project_establishment.php b/database/migrations/2024_11_19_153800_add_field_project_establishment.php new file mode 100644 index 000000000..a6ba2f2f7 --- /dev/null +++ b/database/migrations/2024_11_19_153800_add_field_project_establishment.php @@ -0,0 +1,33 @@ +unsignedInteger('direct_seeding_survival_rate')->nullable(); + }); + Schema::table('project_pitches', function (Blueprint $table) { + $table->unsignedInteger('direct_seeding_survival_rate')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('v2_projects', function (Blueprint $table) { + $table->dropColumn('direct_seeding_survival_rate'); + }); + Schema::table('project_pitches', function (Blueprint $table) { + $table->dropColumn('direct_seeding_survival_rate'); + }); + } +};