#57 scaffolding for flight search

This commit is contained in:
Nabeel Shahzad
2017-08-02 15:29:04 -05:00
parent 07ce5e9a1a
commit 61cb8a75a7
4 changed files with 36 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Frontend;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Repositories\FlightRepository;
use App\Http\Controllers\AppBaseController;
@@ -18,8 +19,16 @@ class FlightController extends AppBaseController
public function index(Request $request)
{
$flights = $this->flightRepo->findByField('active', true);
$where = ['active' => true];
// default restrictions on the flights shown. Handle search differently
if (config('phpvms.only_flights_from_current')) {
$where['dpt_airport_id'] = Auth::user()->curr_airport_id;
}
// TODO: PAGINATION
$flights = $this->flightRepo->findWhere($where);
return $this->view('flights.index', [
'flights' => $flights,
]);
@@ -30,6 +39,17 @@ class FlightController extends AppBaseController
}
public function search(Request $request) {
$where = ['active' => true];
$flights = $this->flightRepo->findWhere($where);
// TODO: PAGINATION
return $this->view('flights.index', [
'flights' => $flights,
]);
}
public function update()
{

View File

@@ -30,10 +30,13 @@ return [
*/
'currency' => 'dollar',
/**
* Restrict showing flights from the user's current airport
*/
'only_flights_from_current' => true,
/**
* Misc Settings
*/
'feed_url' => 'http://forum.phpvms.net/rss/1-announcements-feed.xml/?',
];

View File

@@ -3,10 +3,17 @@
@section('content')
<div class="row">
@include('flash::message')
<div class="col-sm-12">
<div class="col-sm-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>
</div>
@endsection

View File

@@ -12,7 +12,9 @@ Route::group([
], function () {
Route::resource('dashboard', 'DashboardController');
Route::resource('profile', 'ProfileController');
Route::resource('flights', 'FlightController');
Route::match(['get'], 'flights/search', 'FlightController@search');
});
Auth::routes();