Bids are missing subfleets in API response #867 (#868)

Bids are missing subfleets in API response #867
This commit is contained in:
Nabeel S
2020-10-12 12:49:11 -04:00
committed by GitHub
parent 193fbd369d
commit dc007f6d9e
7 changed files with 100 additions and 23 deletions

View File

@@ -13,6 +13,14 @@ use Illuminate\Support\Facades\Log;
class BidService extends Service
{
/** @var FlightService */
private $flightSvc;
public function __construct(FlightService $flightSvc)
{
$this->flightSvc = $flightSvc;
}
/**
* Get a specific bid for a user
*
@@ -35,8 +43,20 @@ class BidService extends Service
*/
public function findBidsForUser(User $user)
{
return Bid::with(['flight', 'flight.simbrief'])
$bids = Bid::with([
'flight',
'flight.simbrief',
'flight.subfleets',
'flight.subfleets.aircraft',
'flight.subfleets.fares',
])
->where(['user_id' => $user->id])->get();
foreach ($bids as $bid) {
$bid->flight = $this->flightSvc->filterSubfleets($user, $bid->flight);
}
return $bids;
}
/**