Fix PirepComment response; 201 to 200 (#654)
This commit is contained in:
@@ -168,8 +168,18 @@ class PirepController extends Controller
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
$with = [
|
||||
'acars',
|
||||
'arr_airport',
|
||||
'dpt_airport',
|
||||
'comments',
|
||||
'flight',
|
||||
'simbrief',
|
||||
'user',
|
||||
];
|
||||
|
||||
$pirep = $this->pirepRepo
|
||||
->with(['acars', 'arr_airport', 'dpt_airport', 'comments', 'flight', 'simbrief', 'user'])
|
||||
->with($with)
|
||||
->find($id);
|
||||
|
||||
return new PirepResource($pirep);
|
||||
|
||||
@@ -68,7 +68,7 @@ class Pirep extends Resource
|
||||
$res['arr_airport'] = new Airport($this->arr_airport);
|
||||
|
||||
$res['position'] = Acars::make($this->whenLoaded('position'));
|
||||
$res['comments'] = PirepComment::make($this->whenLoaded('comments'));
|
||||
$res['comments'] = PirepComment::collection($this->whenLoaded('comments'));
|
||||
$res['user'] = User::make($this->whenLoaded('user'));
|
||||
|
||||
$res['flight'] = Flight::make($this->whenLoaded('flight'));
|
||||
|
||||
@@ -4,6 +4,9 @@ namespace App\Http\Resources;
|
||||
|
||||
use App\Contracts\Resource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\PirepComment
|
||||
*/
|
||||
class PirepComment extends Resource
|
||||
{
|
||||
/**
|
||||
@@ -15,6 +18,10 @@ class PirepComment extends Resource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if (!$this->user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$user = $this->user;
|
||||
|
||||
return [
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace App\Models;
|
||||
use App\Contracts\Model;
|
||||
|
||||
/**
|
||||
* @property string pirep_id
|
||||
* @property int user_id
|
||||
* @property string $pirep_id
|
||||
* @property int $user_id
|
||||
* @property Pirep $pirep
|
||||
* @property User $user
|
||||
*/
|
||||
class PirepComment extends Model
|
||||
{
|
||||
|
||||
@@ -56,7 +56,16 @@ class AcarsRepository extends Repository
|
||||
*/
|
||||
public function getPositions($live_time = 0)
|
||||
{
|
||||
$q = Pirep::with(['aircraft', 'airline', 'arr_airport', 'dpt_airport', 'position', 'user'])
|
||||
$with = [
|
||||
'aircraft',
|
||||
'airline',
|
||||
'arr_airport',
|
||||
'dpt_airport',
|
||||
'position',
|
||||
'user',
|
||||
];
|
||||
|
||||
$q = Pirep::with($with)
|
||||
->where(['state' => PirepState::IN_PROGRESS]);
|
||||
|
||||
if ($live_time !== null && $live_time > 0) {
|
||||
|
||||
Reference in New Issue
Block a user