Skip to content

Commit

Permalink
Add taxon code
Browse files Browse the repository at this point in the history
- Create a model for NeonTaxonomy table
- Add taxonCode to Taxonomy model
- Add taxon code to Taxonomy Controlled targeting output for single taxon API
  • Loading branch information
egbot committed Jul 16, 2024
1 parent d1e3cc4 commit 8fb4ca5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/app/Http/Controllers/TaxonomyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public function showOneTaxon($id, Request $request){
$parStatusResult = $parStatus->get();
$taxonObj->classification = $parStatusResult;

$taxonObj->taxonCodes;

if(!$taxonObj->count()) $taxonObj = ['status' =>false, 'error' => 'Unable to locate inventory based on identifier'];
return response()->json($taxonObj);
}
Expand Down
27 changes: 27 additions & 0 deletions api/app/Models/NeonTaxonomy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable;

class NeonTaxonomy extends Model implements AuthenticatableContract, AuthorizableContract{
use Authenticatable, Authorizable, HasFactory;

protected $table = 'neon_taxonomy';
protected $primaryKey = 'taxonPK';
public $timestamps = false;

protected $fillable = [ ];

protected $hidden = [ 'taxonPK', 'verbatimScientificName', 'tid', 'sciname', 'scientificNameAuthorship', 'family', 'acceptedTaxonCode', 'taxonProtocolCategory',
'vernacular', 'source', 'sourceReference', 'notes', 'initialTimestamp' ];

public function taxa() {
return $this->belongsTo(Taxonomy::class, 'tid', 'tid');
}
}
4 changes: 4 additions & 0 deletions api/app/Models/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ public function descriptions(){
public function media(){
return $this->hasMany(media::class, 'tid', 'tid');
}

public function taxonCodes(){
return $this->hasMany(NeonTaxonomy::class, 'tid', 'tid');
}
}

0 comments on commit 8fb4ca5

Please sign in to comment.