Add AirspaceMap widget; airport overview page
This commit is contained in:
57
app/Http/Controllers/Frontend/AirportController.php
Normal file
57
app/Http/Controllers/Frontend/AirportController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Frontend;
|
||||
|
||||
use App\Interfaces\Controller;
|
||||
use App\Models\User;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\FlightRepository;
|
||||
use Flash;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Request;
|
||||
|
||||
/**
|
||||
* Class HomeController
|
||||
* @package App\Http\Controllers\Frontend
|
||||
*/
|
||||
class AirportController extends Controller
|
||||
{
|
||||
private $airportRepo,
|
||||
$flightRepo;
|
||||
|
||||
public function __construct(
|
||||
AirportRepository $airportRepo,
|
||||
FlightRepository $flightRepo
|
||||
) {
|
||||
$this->airportRepo = $airportRepo;
|
||||
$this->flightRepo = $flightRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the airport
|
||||
*/
|
||||
public function show($id, Request $request)
|
||||
{
|
||||
$id = strtoupper($id);
|
||||
|
||||
$airport = $this->airportRepo->find($id);
|
||||
if (empty($airport)) {
|
||||
Flash::error('Airport not found!');
|
||||
return redirect(route('frontend.dashboard.index'));
|
||||
}
|
||||
|
||||
$inbound_flights = $this->flightRepo->findWhere([
|
||||
'arr_airport_id' => $id,
|
||||
])->all();
|
||||
|
||||
$outbound_flights = $this->flightRepo->findWhere([
|
||||
'dpt_airport_id' => $id,
|
||||
])->all();
|
||||
|
||||
return view('airports.show', [
|
||||
'airport' => $airport,
|
||||
'inbound_flights' => $inbound_flights,
|
||||
'outbound_flights' => $outbound_flights,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use App\Repositories\AirportRepository;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Repositories\FlightRepository;
|
||||
use App\Services\GeoService;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Log;
|
||||
@@ -132,7 +133,6 @@ class FlightController extends Controller
|
||||
$flight = $this->flightRepo->find($id);
|
||||
if (empty($flight)) {
|
||||
Flash::error('Flight not found!');
|
||||
|
||||
return redirect(route('frontend.dashboard.index'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user