diff --git a/app/Console/Commands/OneOff/PopulateTreeSpeciesResearch.php b/app/Console/Commands/OneOff/PopulateTreeSpeciesResearch.php index dfdfeda32..67f4cc12c 100644 --- a/app/Console/Commands/OneOff/PopulateTreeSpeciesResearch.php +++ b/app/Console/Commands/OneOff/PopulateTreeSpeciesResearch.php @@ -81,7 +81,7 @@ protected function parseHeaders(array $headerRow): void $this->assert( count(self::COLUMN_MAPPING) === count($this->columns), - "Not all required columns were found" + 'Not all required columns were found' ); } } diff --git a/app/Console/Commands/OneOff/UpdateTreeCollections.php b/app/Console/Commands/OneOff/UpdateTreeCollections.php new file mode 100644 index 000000000..75608cc2c --- /dev/null +++ b/app/Console/Commands/OneOff/UpdateTreeCollections.php @@ -0,0 +1,31 @@ +update(['collection' => TreeSpecies::COLLECTION_HISTORICAL]); + } +} diff --git a/app/Http/Resources/V2/Organisation/OrganisationResource.php b/app/Http/Resources/V2/Organisation/OrganisationResource.php index fa1ac03a7..71cf87ef0 100644 --- a/app/Http/Resources/V2/Organisation/OrganisationResource.php +++ b/app/Http/Resources/V2/Organisation/OrganisationResource.php @@ -39,8 +39,7 @@ public function toArray($request) 'founding_date' => $this->founding_date, 'description' => $this->description, - 'tree_species' => TreeSpeciesResource::collection($this->treeSpecies), - 'tree_species_restored' => TreeSpeciesResource::collection($this->treeSpeciesRestored), + 'tree_species_historical' => TreeSpeciesResource::collection($this->treeSpeciesHistorical), 'project_pitches' => ProjectPitchResource::collection($this->projectPitches), 'leadership_team' => LeadershipTeamResource::collection($this->leadershipTeam), 'core_team_leaders' => CoreTeamLeaderResource::collection($this->coreTeamLeaders), diff --git a/app/Models/V2/Organisation.php b/app/Models/V2/Organisation.php index 6bd2593c0..2415cb920 100644 --- a/app/Models/V2/Organisation.php +++ b/app/Models/V2/Organisation.php @@ -225,16 +225,10 @@ public static function search($query) ->where('organisations.name', 'like', "%$query%"); } - public function treeSpecies(): MorphMany + public function treeSpeciesHistorical(): MorphMany { return $this->morphMany(TreeSpecies::class, 'speciesable') - ->whereNull('collection'); - } - - public function treeSpeciesRestored(): MorphMany - { - return $this->morphMany(TreeSpecies::class, 'speciesable') - ->where('collection', TreeSpecies::COLLECTION_RESTORED); + ->where('collection', TreeSpecies::COLLECTION_HISTORICAL); } public function owners(): HasMany diff --git a/app/Models/V2/TreeSpecies/TreeSpecies.php b/app/Models/V2/TreeSpecies/TreeSpecies.php index 200740ee3..ed77eb60a 100644 --- a/app/Models/V2/TreeSpecies/TreeSpecies.php +++ b/app/Models/V2/TreeSpecies/TreeSpecies.php @@ -47,7 +47,7 @@ class TreeSpecies extends Model implements EntityRelationModel public const COLLECTION_PLANTED = 'tree-planted'; public const COLLECTION_NON_TREE = 'non-tree'; public const COLLECTION_NURSERY = 'nursery-seedling'; - public const COLLECTION_RESTORED = 'restored'; + public const COLLECTION_HISTORICAL = 'historical-tree-species'; public const COLLECTION_PRIMARY = 'primary'; public static $collections = [ @@ -55,7 +55,7 @@ class TreeSpecies extends Model implements EntityRelationModel self::COLLECTION_PLANTED => 'Planted', self::COLLECTION_NON_TREE => 'Non Tree', self::COLLECTION_NURSERY => 'Nursery Seedling', - self::COLLECTION_RESTORED => 'Restored', + self::COLLECTION_HISTORICAL => 'Historical Tree Species', self::COLLECTION_PRIMARY => 'Primary', ]; diff --git a/config/wri/linked-fields.php b/config/wri/linked-fields.php index 56c75c231..c0d212b5f 100644 --- a/config/wri/linked-fields.php +++ b/config/wri/linked-fields.php @@ -165,11 +165,11 @@ 'input_type' => 'coreTeamLeaders', ], 'org-tree-species-restored' => [ - 'property' => 'treeSpeciesRestored', + 'property' => 'treeSpeciesHistorical', 'label' => 'Tree species restored in landscape', 'resource' => 'App\Http\Resources\V2\TreeSpecies\TreeSpeciesResource', 'input_type' => 'treeSpecies', - 'collection' => 'restored' + 'collection' => 'historical-tree-species' ], 'org-ownership-stake' => [ 'property' => 'ownershipStake',