#57 scaffolding for flight search
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
|
||||
@@ -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/?',
|
||||
|
||||
];
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user