Add aircraft ident to API response

This commit is contained in:
Nabeel Shahzad 2022-02-14 12:53:12 -05:00
parent 78fd8367a1
commit 60cec870f6
2 changed files with 17 additions and 0 deletions

View File

@ -4,6 +4,16 @@ namespace App\Http\Resources;
use App\Contracts\Resource;
/**
* @mixin \App\Models\Aircraft
*/
class Aircraft extends Resource
{
public function toArray($request)
{
$res = parent::toArray($request);
$res['ident'] = $this->ident;
return $res;
}
}

View File

@ -279,6 +279,9 @@ class ApiTest extends TestCase
}
$this->assertCount($size, $subfleet['aircraft']);
foreach ($subfleet['aircraft'] as $aircraft) {
$this->assertNotEmpty($aircraft['ident']);
}
}
}
@ -314,6 +317,7 @@ class ApiTest extends TestCase
$this->assertEquals($body['id'], $aircraft->id);
$this->assertEquals($body['name'], $aircraft->name);
$this->assertNotEmpty($body['ident']);
$this->assertEquals($body['mtow'], $aircraft->mtow);
$this->assertEquals($body['zfw'], $aircraft->zfw);
@ -325,6 +329,9 @@ class ApiTest extends TestCase
$this->assertEquals($body['mtow'], $aircraft->mtow);
$this->assertEquals($body['zfw'], $aircraft->zfw);
$this->assertNotEmpty($body['ident']);
$this->assertEquals($body['ident'], $aircraft->ident);
$resp = $this->get('/api/fleet/aircraft/'.$aircraft->id.'?icao='.$aircraft->icao);
$body = $resp->json()['data'];