view flight bids in flights screen #203
This commit is contained in:
@@ -37,8 +37,7 @@ class FlightController extends Controller
|
||||
AirportRepository $airportRepo,
|
||||
FlightRepository $flightRepo,
|
||||
GeoService $geoSvc
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->airlineRepo = $airlineRepo;
|
||||
$this->airportRepo = $airportRepo;
|
||||
$this->flightRepo = $flightRepo;
|
||||
@@ -51,7 +50,9 @@ class FlightController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$where = ['active' => true];
|
||||
$where = [
|
||||
'active' => true
|
||||
];
|
||||
|
||||
// default restrictions on the flights shown. Handle search differently
|
||||
if (setting('pilots.only_flights_from_current')) {
|
||||
@@ -77,6 +78,27 @@ class FlightController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the user's bids and display them
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function bids(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$flights = $user->flights()->paginate();
|
||||
$saved_flights = $flights->pluck('id')->toArray();
|
||||
|
||||
return view('flights.index', [
|
||||
'title' => 'Bids',
|
||||
'airlines' => $this->airlineRepo->selectBoxList(true),
|
||||
'airports' => $this->airportRepo->selectBoxList(true),
|
||||
'flights' => $flights,
|
||||
'saved' => $saved_flights,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a search request using the Repository search
|
||||
* @param Request $request
|
||||
|
||||
@@ -168,6 +168,18 @@ class User extends Authenticatable
|
||||
return $this->belongsTo(Pirep::class, 'last_pirep_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* These are the flights they've bid on
|
||||
*/
|
||||
public function flights()
|
||||
{
|
||||
return $this->belongsToMany(Flight::class, 'bids');
|
||||
}
|
||||
|
||||
/**
|
||||
* The bid rows
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function bids()
|
||||
{
|
||||
return $this->hasMany(Bid::class, 'user_id');
|
||||
|
||||
@@ -25,6 +25,7 @@ Route::group([
|
||||
], function () {
|
||||
Route::resource('dashboard', 'DashboardController');
|
||||
|
||||
Route::get('flights/bids', 'FlightController@bids')->name('flights.bids');
|
||||
Route::get('flights/search', 'FlightController@search')->name('flights.search');
|
||||
Route::resource('flights', 'FlightController');
|
||||
|
||||
|
||||
@@ -5,19 +5,20 @@
|
||||
<div class="row">
|
||||
@include('flash::message')
|
||||
<div class="col-md-9">
|
||||
<h2 class="description">flights</h2>
|
||||
@include("flights.table")
|
||||
<h2 class="description">{{ $title ?? 'Flights' }}</h2>
|
||||
@include('flights.table')
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@include("flights.search")
|
||||
@include('flights.nav')
|
||||
@include('flights.search')
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 text-center">
|
||||
{{ $flights->links("pagination.default") }}
|
||||
{{ $flights->links('pagination.default') }}
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@include("flights.scripts")
|
||||
@include('flights.scripts')
|
||||
|
||||
|
||||
7
resources/views/layouts/default/flights/nav.blade.php
Normal file
7
resources/views/layouts/default/flights/nav.blade.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="card">
|
||||
<div class="card-block" style="min-height: 0px">
|
||||
<div class="form-group text-right">
|
||||
<a href="{{ route('frontend.flights.bids') }}">My Bids</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,30 +1,31 @@
|
||||
<h2 class="description">search</h2>
|
||||
<div class="card">
|
||||
<h3 class="description">search</h3>
|
||||
<div class="card pull-right">
|
||||
<div class="card-block" style="min-height: 0px">
|
||||
<div class="form-group text-right">
|
||||
{{ Form::open(['route' => 'frontend.flights.search', 'method' => 'GET', 'class'=>'form-inline pull-right']) }}
|
||||
|
||||
<div class="form-group">
|
||||
{{ Form::open([
|
||||
'route' => 'frontend.flights.search',
|
||||
'method' => 'GET',
|
||||
'class'=>'form-inline'
|
||||
]) }}
|
||||
<div>
|
||||
<p>Flight Number</p>
|
||||
{{ Form::text('flight_number', null, ['class' => 'form-control']) }}
|
||||
<p>Flight Number</p>
|
||||
{{ Form::text('flight_number', null, ['class' => 'form-control']) }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>Departure Airport</p>
|
||||
{{ Form::select('dep_icao', $airports, null , ['class' => 'form-control']) }}
|
||||
<div style="margin-top: 10px;">
|
||||
<p>Departure Airport</p>
|
||||
{{ Form::select('dep_icao', $airports, null , ['class' => 'form-control']) }}
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
<div style="margin-top: 10px;">
|
||||
<p>Arrival Airport</p>
|
||||
{{ Form::select('arr_icao', $airports, null , ['class' => 'form-control']) }}
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div class="">
|
||||
<div class="clear" style="margin-top: 10px;">
|
||||
{{ Form::submit('find', ['class' => 'btn btn-primary']) }}
|
||||
<a href="{{ route('frontend.flights.index') }}">clear</a>
|
||||
</div>
|
||||
<br />
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 class="description">{{ $flight->ident }} - {{ $flight->dpt_airport->full_name }} to {{ $flight->arr_airport->full_name }}</h3>
|
||||
<h2 class="description">{{ $flight->ident }} - {{ $flight->dpt_airport->full_name }} to {{ $flight->arr_airport->full_name }}</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url('/pireps') }}">
|
||||
<i class="fas fa-cloud-upload-alt"></i>
|
||||
<p>Flight Reports</p>
|
||||
<p>PIREPs</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3 class="description">flight map</h3>
|
||||
<h2 class="description">Current Flights</h2>
|
||||
<div class="box-body">
|
||||
<div id="map" style="width: {{ $config['width'] }}; height: {{ $config['height'] }}"></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user