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