@@ -9,6 +9,7 @@ use App\Http\Resources\Navdata as NavdataResource;
|
||||
use App\Models\SimBrief;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\FareService;
|
||||
use App\Services\FlightService;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,19 +19,26 @@ use Prettus\Repository\Exceptions\RepositoryException;
|
||||
|
||||
class FlightController extends Controller
|
||||
{
|
||||
/** @var \App\Services\FareService */
|
||||
private $fareSvc;
|
||||
|
||||
/** @var \App\Repositories\FlightRepository */
|
||||
private $flightRepo;
|
||||
|
||||
/** @var \App\Services\FlightService */
|
||||
private $flightSvc;
|
||||
|
||||
/**
|
||||
* FlightController constructor.
|
||||
*
|
||||
* @param FareService $fareSvc
|
||||
* @param FlightRepository $flightRepo
|
||||
* @param FlightService $flightSvc
|
||||
*/
|
||||
public function __construct(
|
||||
FareService $fareSvc,
|
||||
FlightRepository $flightRepo,
|
||||
FlightService $flightSvc
|
||||
) {
|
||||
$this->fareSvc = $fareSvc;
|
||||
$this->flightRepo = $flightRepo;
|
||||
$this->flightSvc = $flightSvc;
|
||||
}
|
||||
@@ -71,6 +79,7 @@ class FlightController extends Controller
|
||||
])->find($id);
|
||||
|
||||
$flight = $this->flightSvc->filterSubfleets($user, $flight);
|
||||
$flight = $this->fareSvc->getReconciledFaresForFlight($flight);
|
||||
|
||||
return new FlightResource($flight);
|
||||
}
|
||||
@@ -130,6 +139,7 @@ class FlightController extends Controller
|
||||
// TODO: Remove any flights here that a user doesn't have permissions to
|
||||
foreach ($flights as $flight) {
|
||||
$this->flightSvc->filterSubfleets($user, $flight);
|
||||
$this->fareSvc->getReconciledFaresForFlight($flight);
|
||||
}
|
||||
|
||||
return FlightResource::collection($flights);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Contracts\Resource;
|
||||
use App\Services\FareService;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Fare
|
||||
@@ -12,17 +11,13 @@ class Fare extends Resource
|
||||
{
|
||||
public function toArray($request)
|
||||
{
|
||||
/** @var FareService $fareSvc */
|
||||
$fareSvc = app(FareService::class);
|
||||
$fare = $fareSvc->getFares($this);
|
||||
|
||||
return [
|
||||
'id' => $fare->id,
|
||||
'code' => $fare->code,
|
||||
'name' => $fare->name,
|
||||
'capacity' => $fare->capacity,
|
||||
'cost' => $fare->cost,
|
||||
'price' => $fare->price,
|
||||
'id' => $this->id,
|
||||
'code' => $this->code,
|
||||
'name' => $this->name,
|
||||
'capacity' => $this->capacity,
|
||||
'cost' => $this->cost,
|
||||
'price' => $this->price,
|
||||
'type' => $this->type,
|
||||
'notes' => $this->notes,
|
||||
'active' => $this->active,
|
||||
|
||||
@@ -58,7 +58,6 @@ class Flight extends Resource
|
||||
|
||||
$res['airline'] = new Airline($this->airline);
|
||||
$res['subfleets'] = Subfleet::collection($this->whenLoaded('subfleets'));
|
||||
$res['fares'] = Fare::collection($this->whenLoaded('fares'));
|
||||
$res['fields'] = $this->setFields();
|
||||
|
||||
// Simbrief info
|
||||
|
||||
Reference in New Issue
Block a user