Skip to content

Commit

Permalink
Flight search on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Dec 4, 2017
1 parent 84c610c commit 9c1a8f8
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 20 deletions.
25 changes: 18 additions & 7 deletions app/Http/Controllers/Frontend/FlightController.php
Expand Up @@ -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;

public function __construct(FlightRepository $flightRepo)
{
private $airlineRepo, $airportRepo, $flightRepo;

public function __construct(
AirlineRepository $airlineRepo,
AirportRepository $airportRepo,
FlightRepository $flightRepo
) {
$this->airlineRepo = $airlineRepo;
$this->airportRepo = $airportRepo;
$this->flightRepo = $flightRepo;
}

Expand All @@ -45,6 +52,8 @@ public function index(Request $request)
->pluck('flight_id')->toArray();

return $this->view('flights.index', [
'airlines' => $this->airlineRepo->selectBoxList(true),
'airports' => $this->airportRepo->selectBoxList(true),
'flights' => $flights,
'saved' => $saved_flights,
]);
Expand All @@ -64,6 +73,8 @@ public function search(Request $request)
->pluck('flight_id')->toArray();

return $this->view('flights.index', [
'airlines' => $this->airlineRepo->selectBoxList(true),
'airports' => $this->airportRepo->selectBoxList(true),
'flights' => $flights,
'saved' => $saved_flights,
]);
Expand Down
10 changes: 3 additions & 7 deletions resources/views/layouts/default/flights/index.blade.php
Expand Up @@ -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">
Expand Down
31 changes: 31 additions & 0 deletions resources/views/layouts/default/flights/search.blade.php
@@ -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>
12 changes: 6 additions & 6 deletions routes/web.php
@@ -1,15 +1,15 @@
<?php

Route::get('/', 'HomeController@index');
Route::get('/', 'HomeController@index')->name('home');

/**
* User doesn't need to be logged in for these
*/
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');
});

/**
Expand All @@ -21,15 +21,15 @@
], 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');

0 comments on commit 9c1a8f8

Please sign in to comment.