2017-06-09 09:02:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
2019-07-16 03:51:35 +08:00
|
|
|
use App\Contracts\Controller;
|
2018-02-21 12:33:09 +08:00
|
|
|
use App\Http\Requests\CreateAirlineRequest;
|
|
|
|
use App\Http\Requests\UpdateAirlineRequest;
|
|
|
|
use App\Repositories\AirlineRepository;
|
2018-02-13 00:51:04 +08:00
|
|
|
use App\Support\Countries;
|
2017-12-31 02:53:16 +08:00
|
|
|
use Flash;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Prettus\Repository\Criteria\RequestCriteria;
|
2018-02-21 12:33:09 +08:00
|
|
|
use Response;
|
2017-06-09 09:02:52 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* Class AirlinesController
|
|
|
|
*/
|
|
|
|
class AirlinesController extends Controller
|
2017-06-09 09:02:52 +08:00
|
|
|
{
|
2017-06-20 00:50:25 +08:00
|
|
|
private $airlineRepo;
|
2017-06-09 09:02:52 +08:00
|
|
|
|
2018-02-21 12:33:09 +08:00
|
|
|
/**
|
|
|
|
* AirlinesController constructor.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-02-21 12:33:09 +08:00
|
|
|
* @param AirlineRepository $airlinesRepo
|
|
|
|
*/
|
2018-08-27 00:40:04 +08:00
|
|
|
public function __construct(AirlineRepository $airlinesRepo)
|
|
|
|
{
|
2017-06-20 00:50:25 +08:00
|
|
|
$this->airlineRepo = $airlinesRepo;
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display a listing of the Airlines.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-02-13 00:51:04 +08:00
|
|
|
* @throws \Prettus\Repository\Exceptions\RepositoryException
|
2017-06-09 09:02:52 +08:00
|
|
|
*/
|
|
|
|
public function index(Request $request)
|
|
|
|
{
|
2017-06-20 00:50:25 +08:00
|
|
|
$this->airlineRepo->pushCriteria(new RequestCriteria($request));
|
|
|
|
$airlines = $this->airlineRepo->all();
|
2017-06-09 09:02:52 +08:00
|
|
|
|
2018-03-12 06:22:25 +08:00
|
|
|
return view('admin.airlines.index', [
|
|
|
|
'airlines' => $airlines,
|
|
|
|
]);
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new Airlines.
|
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
2018-02-13 00:51:04 +08:00
|
|
|
return view('admin.airlines.create', [
|
|
|
|
'countries' => Countries::getSelectList(),
|
|
|
|
]);
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created Airlines in storage.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-23 06:17:37 +08:00
|
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
2017-06-09 09:02:52 +08:00
|
|
|
*/
|
2017-06-20 00:50:25 +08:00
|
|
|
public function store(CreateAirlineRequest $request)
|
2017-06-09 09:02:52 +08:00
|
|
|
{
|
|
|
|
$input = $request->all();
|
2017-06-20 00:50:25 +08:00
|
|
|
$airlines = $this->airlineRepo->create($input);
|
2017-06-09 09:02:52 +08:00
|
|
|
|
|
|
|
Flash::success('Airlines saved successfully.');
|
2017-07-08 05:49:03 +08:00
|
|
|
return redirect(route('admin.airlines.index'));
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified Airlines.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
*
|
2017-06-11 11:17:45 +08:00
|
|
|
* @return mixed
|
2017-06-09 09:02:52 +08:00
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
2017-06-20 00:50:25 +08:00
|
|
|
$airlines = $this->airlineRepo->findWithoutFail($id);
|
2017-06-09 09:02:52 +08:00
|
|
|
|
|
|
|
if (empty($airlines)) {
|
|
|
|
Flash::error('Airlines not found');
|
2017-07-08 05:49:03 +08:00
|
|
|
return redirect(route('admin.airlines.index'));
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
2018-02-13 00:51:04 +08:00
|
|
|
return view('admin.airlines.show', [
|
|
|
|
'airlines' => $airlines,
|
|
|
|
]);
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified Airlines.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
*
|
2017-06-09 09:02:52 +08:00
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
2017-11-23 10:03:49 +08:00
|
|
|
$airline = $this->airlineRepo->findWithoutFail($id);
|
2017-06-09 09:02:52 +08:00
|
|
|
|
2017-11-23 10:03:49 +08:00
|
|
|
if (empty($airline)) {
|
|
|
|
Flash::error('Airline not found');
|
2017-07-08 05:49:03 +08:00
|
|
|
return redirect(route('admin.airlines.index'));
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
2018-02-13 00:51:04 +08:00
|
|
|
return view('admin.airlines.edit', [
|
2018-03-20 09:50:40 +08:00
|
|
|
'airline' => $airline,
|
2018-02-13 00:51:04 +08:00
|
|
|
'countries' => Countries::getSelectList(),
|
|
|
|
]);
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified Airlines in storage.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param int $id
|
2017-06-20 00:50:25 +08:00
|
|
|
* @param UpdateAirlineRequest $request
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-02-13 00:51:04 +08:00
|
|
|
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @return Response
|
2017-06-09 09:02:52 +08:00
|
|
|
*/
|
2017-06-20 00:50:25 +08:00
|
|
|
public function update($id, UpdateAirlineRequest $request)
|
2017-06-09 09:02:52 +08:00
|
|
|
{
|
2017-06-20 00:50:25 +08:00
|
|
|
$airlines = $this->airlineRepo->findWithoutFail($id);
|
2017-06-09 09:02:52 +08:00
|
|
|
|
|
|
|
if (empty($airlines)) {
|
|
|
|
Flash::error('Airlines not found');
|
2017-07-08 05:49:03 +08:00
|
|
|
return redirect(route('admin.airlines.index'));
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
2017-06-20 00:50:25 +08:00
|
|
|
$airlines = $this->airlineRepo->update($request->all(), $id);
|
2017-06-09 09:02:52 +08:00
|
|
|
|
|
|
|
Flash::success('Airlines updated successfully.');
|
2017-07-08 05:49:03 +08:00
|
|
|
return redirect(route('admin.airlines.index'));
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified Airlines from storage.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
*
|
2017-06-09 09:02:52 +08:00
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
2017-06-20 00:50:25 +08:00
|
|
|
$airlines = $this->airlineRepo->findWithoutFail($id);
|
2017-06-09 09:02:52 +08:00
|
|
|
|
|
|
|
if (empty($airlines)) {
|
|
|
|
Flash::error('Airlines not found');
|
2017-07-08 05:49:03 +08:00
|
|
|
return redirect(route('admin.airlines.index'));
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
|
2017-06-20 00:50:25 +08:00
|
|
|
$this->airlineRepo->delete($id);
|
2017-06-09 09:02:52 +08:00
|
|
|
|
|
|
|
Flash::success('Airlines deleted successfully.');
|
2017-07-08 05:49:03 +08:00
|
|
|
return redirect(route('admin.airlines.index'));
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
|
|
|
}
|