#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()
{