Skip to content

Commit

Permalink
feat: added new field for PR and SR
Browse files Browse the repository at this point in the history
  • Loading branch information
Scriptmatico committed Dec 9, 2024
1 parent 2b7366c commit c870bee
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/Models/V2/Projects/ProjectReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,16 @@ class ProjectReport extends Model implements MediaModel, AuditableContract, Repo
'beneficiaries_scstobc_farmers',
'beneficiaries_scstobc',
'total_unique_restoration_partners',

'business_milestones',
'ft_other',
'pt_other',
'volunteer_other',
'beneficiaries_other',
'beneficiaries_training_women',
'beneficiaries_training_men',
'beneficiaries_training_other',
'beneficiaries_training_youth',
'beneficiaries_training_non_youth',
// virtual (see HasWorkdays trait)
'other_workdays_description',
// virtual (see HasRestorationPartners trait)
Expand Down
10 changes: 9 additions & 1 deletion app/Models/V2/Sites/SiteReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ class SiteReport extends Model implements MediaModel, AuditableContract, ReportM
'water_structures',
'site_community_partners_description',
'site_community_partners_income_increase_description',

'pct_survival_to_date',
'survival_calculation',
'survival_description',
'maintenance_activities',
// virtual (see HasWorkdays trait)
'other_workdays_description',
];
Expand Down Expand Up @@ -239,6 +242,11 @@ public function nonTreeSpecies()
return $this->morphMany(TreeSpecies::class, 'speciesable')->where('collection', 'non-tree');
}

public function replantingTreeSpecies()
{
return $this->morphMany(TreeSpecies::class, 'speciesable')->where('collection', 'replanting');
}

public function seedings(): MorphMany
{
return $this->morphMany(Seeding::class, 'seedable');
Expand Down
23 changes: 23 additions & 0 deletions config/wri/linked-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,17 @@
'pro-rep-indirect-beneficiaries-description' => ['property' => 'indirect_beneficiaries_description', 'label' => 'Indirect Beneficiaries Description', 'input_type' => 'long-text'],
'pro-rep-other-restoration-partners-description' => ['property' => 'other_restoration_partners_description', 'label' => 'Other Restoration Partners Description', 'input_type' => 'long-text'],
'pro-rep-total-unique-restoration-partners' => ['property' => 'total_unique_restoration_partners', 'label' => 'Total Unique Restoration Partners', 'input_type' => 'number'],
// New fields TM-1542
'pro-rep-business-milestones' => ['property' => 'business_milestones', 'label' => 'Business Milestones', 'input_type' => 'long-text'],
'pro-rep-ft-other' => ['property' => 'ft_other', 'label' => 'Full Time Other Gender', 'input_type' => 'number'],
'pro-rep-pt-other' => ['property' => 'pt_other', 'label' => 'Part Time Other Gender', 'input_type' => 'number'],
'pro-rep-volunteer_other' => ['property' => 'volunteer_other', 'label' => 'Volunteer Other Gender', 'input_type' => 'number'],
'pro-rep-beneficiaries-other' => ['property' => 'beneficiaries_other', 'label' => 'Other Gender Beneficiary', 'input_type' => 'number'],
'pro-rep-beneficiaries-training-women' => ['property' => 'beneficiaries_training_women', 'label' => 'Women Trained', 'input_type' => 'number'],
'pro-rep-beneficiaries-training-men' => ['property' => 'beneficiaries_training_men', 'label' => 'Men Trained', 'input_type' => 'number'],
'pro-rep-beneficiaries-training-other' => ['property' => 'beneficiaries_training_other', 'label' => 'Other Gender Trained', 'input_type' => 'number'],
'pro-rep-beneficiaries-training-youth' => ['property' => 'beneficiaries_training_youth', 'label' => 'Youth Trained', 'input_type' => 'number'],
'pro-rep-beneficiaries-training-non-youth' => ['property' => 'beneficiaries_training_non_youth', 'label' => 'Non Youth Trained', 'input_type' => 'number'],
],
'relations' => [
'pro-rep-rel-tree-species' => [
Expand Down Expand Up @@ -784,6 +795,11 @@
'site-rep-other-workdays-description' => ['property' => 'other_workdays_description', 'label' => 'Other Activities Description', 'input_type' => 'long-text'],
'site-rep-num-trees-regenerating' => ['property' => 'num_trees_regenerating', 'label' => 'Estimate Number of Trees Restored via ANR', 'input_type' => 'number'],
'site-rep-regeneration-description' => ['property' => 'regeneration_description', 'label' => 'Description of ANR Activities', 'input_type' => 'long-text'],
// New fields TM-1542
'site-rep-pct-survival-to-date' => ['property' => 'pct_survival_to_date', 'label' => 'Survival Rate', 'input_type' => 'number'],
'site-rep-survival-calculation' => ['property' => 'survival_calculation', 'label' => 'Description of Survival Rate Calculation', 'input_type' => 'long-text'],
'site-rep-survival-description' => ['property' => 'survival_description', 'label' => 'Explanation of Survival Rate', 'input_type' => 'long-text'],
'site-rep-maintenance-activities' => ['property' => 'maintenance_activities', 'label' => 'Maintenance Activities', 'input_type' => 'long-text'],
],
'file-collections' => [
'site-rep-col-media' => ['property' => 'media', 'label' => 'Media', 'input_type' => 'file', 'multichoice' => true],
Expand All @@ -796,6 +812,13 @@
'site-rep-col-site-submission' => ['property' => 'site_submission', 'label' => 'Site submission', 'input_type' => 'file', 'multichoice' => true],
],
'relations' => [
'site-rep-rel-replanting-tree-species' => [
'property' => 'replantingTreeSpecies',
'label' => 'Replanting Species + Count',
'resource' => 'App\Http\Resources\V2\TreeSpecies\TreeSpeciesResource',
'input_type' => 'treeSpecies',
'collection' => 'replanting',
],
'site-rep-rel-tree-species' => [
'property' => 'treeSpecies',
'label' => 'Tree Species',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?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_project_reports', function (Blueprint $table) {
$table->longText('business_milestones')->nullable();
$table->unsignedInteger('ft_other')->nullable();
$table->unsignedInteger('pt_other')->nullable();
$table->unsignedInteger('volunteer_other')->nullable();
$table->unsignedInteger('beneficiaries_other')->nullable();
$table->unsignedInteger('beneficiaries_training_women')->nullable();
$table->unsignedInteger('beneficiaries_training_men')->nullable();
$table->unsignedInteger('beneficiaries_training_other')->nullable();
$table->unsignedInteger('beneficiaries_training_youth')->nullable();
$table->unsignedInteger('beneficiaries_training_non_youth')->nullable();
});

Schema::table('v2_site_reports', function (Blueprint $table) {
$table->unsignedInteger('pct_survival_to_date')->nullable();
$table->longText('survival_calculation')->nullable();
$table->longText('survival_description')->nullable();
$table->longText('maintenance_activities')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
//
Schema::table('v2_project_reports', function (Blueprint $table) {
$table->dropColumn('business_milestones');
$table->dropColumn('ft_other');
$table->dropColumn('pt_other');
$table->dropColumn('volunteer_other');
$table->dropColumn('beneficiaries_other');
$table->dropColumn('beneficiaries_training_women');
$table->dropColumn('beneficiaries_training_men');
$table->dropColumn('beneficiaries_training_other');
$table->dropColumn('beneficiaries_training_youth');
$table->dropColumn('beneficiaries_training_non_youth');
});

Schema::table('v2_site_reports', function (Blueprint $table) {
$table->dropColumn('pct_survival_to_date');
$table->dropColumn('survival_calculation');
$table->dropColumn('survival_description');
$table->dropColumn('maintenance_activities');
});
}
};

0 comments on commit c870bee

Please sign in to comment.