show all flights in admin/active by default
This commit is contained in:
parent
70f1a6ee02
commit
81d349d78d
@ -54,7 +54,7 @@ class FlightController extends BaseController
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$flights = $this->flightRepo->searchCriteria($request)->paginate();
|
||||
$flights = $this->flightRepo->searchCriteria($request, false)->paginate();
|
||||
return view('admin.flights.index', [
|
||||
'flights' => $flights,
|
||||
'airlines' => $this->airlineRepo->selectBoxList(true),
|
||||
@ -85,6 +85,8 @@ class FlightController extends BaseController
|
||||
{
|
||||
$input = $request->all();
|
||||
|
||||
$input['active'] = true;
|
||||
|
||||
$flight = $this->flightRepo->create($input);
|
||||
|
||||
Flash::success('Flight saved successfully.');
|
||||
@ -148,7 +150,9 @@ class FlightController extends BaseController
|
||||
return redirect(route('admin.flights.index'));
|
||||
}
|
||||
|
||||
$flight = $this->flightRepo->update($request->all(), $id);
|
||||
$attrs = $request->all();
|
||||
$attrs['active'] = true;
|
||||
$flight = $this->flightRepo->update($attrs, $id);
|
||||
|
||||
Flash::success('Flight updated successfully.');
|
||||
return redirect(route('admin.flights.index'));
|
||||
|
@ -35,9 +35,11 @@ class FlightRepository extends BaseRepository implements CacheableInterface
|
||||
*/
|
||||
public function searchCriteria(Request $request, bool $only_active=true)
|
||||
{
|
||||
$where = [
|
||||
'active' => $only_active,
|
||||
];
|
||||
$where = [];
|
||||
|
||||
if($only_active === true) {
|
||||
$where['active'] = $only_active;
|
||||
}
|
||||
|
||||
if ($request->filled('flight_id')) {
|
||||
$where['id'] = $request->flight_id;
|
||||
|
Loading…
Reference in New Issue
Block a user