diff --git a/app/Http/Resources/Pirep.php b/app/Http/Resources/Pirep.php index 67cab45f..34c60e4f 100644 --- a/app/Http/Resources/Pirep.php +++ b/app/Http/Resources/Pirep.php @@ -14,6 +14,13 @@ class Pirep extends Resource */ public function toArray($request) { - return parent::toArray($request); + $pirep = parent::toArray($request); + + $pirep['airline'] = new Airline($this->airline); + $pirep['dpt_airport'] = new Airport($this->dpt_airport); + $pirep['arr_airport'] = new Airport($this->arr_airport); + $pirep['position'] = new Acars($this->position); + + return $pirep; } } diff --git a/tests/AcarsTest.php b/tests/AcarsTest.php index bdd6e336..6a2c5fc8 100644 --- a/tests/AcarsTest.php +++ b/tests/AcarsTest.php @@ -82,7 +82,10 @@ class AcarsTest extends TestCase $response->assertStatus(201); # Get the PIREP ID - $pirep_id = $response->json()['id']; + $body = $response->json(); + $pirep_id = $body['id']; + + $this->assertHasKeys($body, ['airline', 'arr_airport', 'dpt_airport', 'position']); $this->assertNotNull($pirep_id); # Check the PIREP state and status