Skip to content

Commit

Permalink
[TM-1472] add direct seeding survival rate to project stablishment
Browse files Browse the repository at this point in the history
  • Loading branch information
LimberHope committed Nov 20, 2024
1 parent e1913a8 commit a6dc950
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions app/Http/Resources/V2/Projects/ProjectResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions app/Models/V2/Projects/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 2 additions & 0 deletions config/wri/linked-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('v2_projects', function (Blueprint $table) {
$table->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');
});
}
};

0 comments on commit a6dc950

Please sign in to comment.