diff --git a/app/Http/Controllers/Frontend/FlightController.php b/app/Http/Controllers/Frontend/FlightController.php index e8dcafda..3d967e68 100644 --- a/app/Http/Controllers/Frontend/FlightController.php +++ b/app/Http/Controllers/Frontend/FlightController.php @@ -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() { diff --git a/config/phpvms.php b/config/phpvms.php index dd45ad7a..35b33c3f 100644 --- a/config/phpvms.php +++ b/config/phpvms.php @@ -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/?', - ]; diff --git a/resources/views/layouts/default/flights/index.blade.php b/resources/views/layouts/default/flights/index.blade.php index 16e03c26..1f556423 100644 --- a/resources/views/layouts/default/flights/index.blade.php +++ b/resources/views/layouts/default/flights/index.blade.php @@ -3,10 +3,17 @@ @section('content')
@include('flash::message') -
+

flights

@include('layouts.default.flights.table')
+
+

search

+
+
+
+
+
@endsection diff --git a/routes/web.php b/routes/web.php index bd25d351..ab00b7ad 100755 --- a/routes/web.php +++ b/routes/web.php @@ -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();