Update response objects
This commit is contained in:
@@ -119,11 +119,15 @@ class AcarsController extends Controller
|
||||
public function acars_get($id, Request $request)
|
||||
{
|
||||
$this->pirepRepo->find($id);
|
||||
$acars = Acars::with(['pirep'])
|
||||
->where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::FLIGHT_PATH,
|
||||
])
|
||||
->orderBy('sim_time', 'asc')
|
||||
->get();
|
||||
|
||||
return new AcarsRouteResource(Acars::where([
|
||||
'pirep_id' => $id,
|
||||
'type' => AcarsType::FLIGHT_PATH,
|
||||
])->orderBy('sim_time', 'asc')->get());
|
||||
return new AcarsRouteResource($acars);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,9 @@ use App\Contracts\Resource;
|
||||
use App\Support\Units\Distance;
|
||||
use App\Support\Units\Fuel;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Acars
|
||||
*/
|
||||
class Acars extends Resource
|
||||
{
|
||||
/**
|
||||
@@ -31,6 +34,8 @@ class Acars extends Resource
|
||||
$fuel = new Fuel($fuel, config('phpvms.internal_units.fuel'));
|
||||
$res['fuel'] = $fuel->getResponseUnits();
|
||||
|
||||
$res['pirep'] = Pirep::make($this->whenLoaded('pirep'));
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ class Pirep extends Resource
|
||||
$res['dpt_airport'] = new Airport($this->dpt_airport);
|
||||
$res['arr_airport'] = new Airport($this->arr_airport);
|
||||
|
||||
$res['position'] = new Acars($this->position);
|
||||
$res['comments'] = PirepComment::collection($this->comments);
|
||||
$res['position'] = Acars::make($this->whenLoaded('position'));
|
||||
$res['comments'] = PirepComment::make($this->whenLoaded('comments'));
|
||||
$res['user'] = [
|
||||
'id' => $this->user->id,
|
||||
'name' => $this->user->name,
|
||||
|
||||
@@ -8,16 +8,14 @@ use App\Support\Units\Distance;
|
||||
use App\Support\Units\Fuel;
|
||||
|
||||
/**
|
||||
* Class Acars
|
||||
*
|
||||
* @param string id
|
||||
*
|
||||
* @property string id
|
||||
* @property string pirep_id
|
||||
* @property int type
|
||||
* @property string name
|
||||
* @property float lat
|
||||
* @property float lon
|
||||
* @property float altitude
|
||||
* @property float lat
|
||||
* @property float lon
|
||||
* @property float altitude
|
||||
* @property int gs
|
||||
* @property int heading
|
||||
* @property int order
|
||||
|
||||
Reference in New Issue
Block a user