Flight search on frontend

This commit is contained in:
Nabeel Shahzad 2017-12-04 14:21:46 -06:00
parent 84c610c6c1
commit 9c1a8f8251
4 changed files with 57 additions and 19 deletions

View File

@ -2,25 +2,32 @@
namespace App\Http\Controllers\Frontend;
use App\Repositories\AirlineRepository;
use App\Repositories\AirportRepository;
use Log;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Repositories\FlightRepository;
use App\Http\Controllers\AppBaseController;
use App\Http\Controllers\AppBaseController;
use App\Models\UserFlight;
use App\Repositories\FlightRepository;
use App\Repositories\Criteria\WhereCriteria;
use Mockery\Exception;
use Prettus\Repository\Criteria\RequestCriteria;
use Prettus\Repository\Exceptions\RepositoryException;
class FlightController extends AppBaseController
{
private $flightRepo;
private $airlineRepo, $airportRepo, $flightRepo;
public function __construct(FlightRepository $flightRepo)
{
public function __construct(
AirlineRepository $airlineRepo,
AirportRepository $airportRepo,
FlightRepository $flightRepo
) {
$this->airlineRepo = $airlineRepo;
$this->airportRepo = $airportRepo;
$this->flightRepo = $flightRepo;
}
@ -45,6 +52,8 @@ class FlightController extends AppBaseController
->pluck('flight_id')->toArray();
return $this->view('flights.index', [
'airlines' => $this->airlineRepo->selectBoxList(true),
'airports' => $this->airportRepo->selectBoxList(true),
'flights' => $flights,
'saved' => $saved_flights,
]);
@ -64,6 +73,8 @@ class FlightController extends AppBaseController
->pluck('flight_id')->toArray();
return $this->view('flights.index', [
'airlines' => $this->airlineRepo->selectBoxList(true),
'airports' => $this->airportRepo->selectBoxList(true),
'flights' => $flights,
'saved' => $saved_flights,
]);

View File

@ -3,16 +3,12 @@
@section('content')
<div class="row">
@include('flash::message')
<div class="col-sm-9">
<div class="col-md-9">
<h2 class="description">flights</h2>
@include('layouts.default.flights.table')
</div>
<div class="col-sm-3">
<h2 class="description">search</h2>
<div class="card">
<div class="card-block" style="min-height: 0px">
</div>
</div>
<div class="col-md-3">
@include('layouts.default.flights.search')
</div>
</div>
<div class="row">

View File

@ -0,0 +1,31 @@
<h2 class="description">search</h2>
<div class="card">
<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>
<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>
<div class="">
<p>Arrival Airport</p>
{!! Form::select('arr_icao', $airports, null , ['class' => 'form-control']) !!}
</div>
<br />
<div class="">
{!! Form::submit('find', ['class' => 'btn btn-primary']) !!}&nbsp;
<a href="{!! route('frontend.flights.index') !!}">clear</a>
</div>
<br />
{!! Form::close() !!}
</div>
</div>
</div>

View File

@ -1,6 +1,6 @@
<?php
Route::get('/', 'HomeController@index');
Route::get('/', 'HomeController@index')->name('home');
/**
* User doesn't need to be logged in for these
@ -8,8 +8,8 @@ Route::get('/', 'HomeController@index');
Route::group([
'namespace' => 'Frontend', 'prefix' => '', 'as' => 'frontend.'
], function() {
Route::get('/r/{id}', 'PirepController@show');
Route::get('/p/{id}', 'ProfileController@show');
Route::get('/r/{id}', 'PirepController@show')->name('pirep.show.public');
Route::get('/p/{id}', 'ProfileController@show')->name('profile.show.public');
});
/**
@ -21,15 +21,15 @@ Route::group([
], function () {
Route::resource('dashboard', 'DashboardController');
Route::get('flights/search', 'FlightController@search')->name('flights.search');
Route::match(['post'], '/flights/save', 'FlightController@save')->name('flights.save');
Route::resource('flights', 'FlightController');
Route::match(['get'], 'flights/search', 'FlightController@search');
Route::match(['post'], 'flights/save', 'FlightController@save');
Route::resource('profile', 'ProfileController');
Route::resource('pireps', 'PirepController');
});
Auth::routes();
Route::get('/logout', 'Auth\LoginController@logout');
Route::get('/logout', 'Auth\LoginController@logout')->name('logout');
require base_path('routes/admin.php');