Load Simbrief and flight data when getting bids #664 (#665)

This commit is contained in:
Nabeel S
2020-04-15 10:11:06 -04:00
committed by GitHub
parent b1bdd40da7
commit 8e97a7cc5c
3 changed files with 40 additions and 4 deletions

View File

@@ -13,6 +13,19 @@ use Illuminate\Support\Facades\Log;
class BidService extends Service
{
/**
* Get a specific bid for a user
*
* @param $bid_id
*
* @return \App\Models\Bid|\Illuminate\Database\Eloquent\Model|object|null
*/
public function getBid($bid_id)
{
return Bid::with(['flight', 'flight.simbrief'])
->where(['id' => $bid_id])->first();
}
/**
* Find all of the bids for a given user
*
@@ -22,8 +35,8 @@ class BidService extends Service
*/
public function findBidsForUser(User $user)
{
$bids = Bid::where(['user_id' => $user->id])->get();
return $bids;
return Bid::with(['flight', 'flight.simbrief'])
->where(['user_id' => $user->id])->get();
}
/**
@@ -86,7 +99,7 @@ class BidService extends Service
$flight->has_bid = true;
$flight->save();
return $bid;
return $this->getBid($bid->id);
}
/**