Fix the user api response, don't return bids by default, fix flights column #639
This commit is contained in:
@@ -90,7 +90,7 @@ class UserController extends Controller
|
||||
public function get($id)
|
||||
{
|
||||
$user = $this->userRepo
|
||||
->with(['airline', 'bids', 'rank'])
|
||||
->with(['airline', 'rank'])
|
||||
->find($id);
|
||||
|
||||
return new UserResource($user);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Contracts\Resource;
|
||||
use App\Http\Resources\Flight as FlightResource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\User
|
||||
@@ -30,7 +29,6 @@ class User extends Resource
|
||||
|
||||
$res['airline'] = Airline::make($this->airline);
|
||||
$res['bids'] = UserBid::collection($this->whenLoaded('bids'));
|
||||
$res['flights'] = new FlightResource($this->whenLoaded('flights'));
|
||||
$res['rank'] = Rank::make($this->rank);
|
||||
|
||||
/*
|
||||
|
||||
@@ -4,17 +4,20 @@ namespace App\Http\Resources;
|
||||
|
||||
use App\Contracts\Resource;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Bid
|
||||
*/
|
||||
class UserBid extends Resource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'user_id' => $this->user_id,
|
||||
'flight_id' => $this->flight_id,
|
||||
'flights' => Flight::collection($this->whenLoaded('flight')),
|
||||
//'created_at' => $this->created_at,
|
||||
//'updated_at' => $this->updated_at,
|
||||
'id' => $this->id,
|
||||
'user_id' => $this->user_id,
|
||||
'flight_id' => $this->flight_id,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'flight' => new Flight($this->whenLoaded('flight')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user