getCompletedTests(); $tests = array_values(array_filter($tests, function(Test $test) use ($test_id) { return $test->id == $test_id; })); if(!$tests) { JSON::fail(); } /** @var Test $test */ $test = $tests[0]; JSON::success([ "invoiceGenerated" => $test->hasTesterInvoicePDF(), "travelCosts" => (float) $test->test_travel_cost, "travelCostDescription" => $test->test_travel_cost_description ]);