Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-1472] add direct seeding survival rate to project stablishment #580

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
}
};
Loading