phpvms/app/Http/Controllers/Admin/AirlinesController.php
2017-12-30 12:53:16 -06:00

142 lines
3.4 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use Flash;
use Response;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Http\Requests\CreateAirlineRequest;
use App\Http\Requests\UpdateAirlineRequest;
use App\Repositories\AirlineRepository;
class AirlinesController extends BaseController
{
/** @var AirlineRepository */
private $airlineRepo;
public function __construct(AirlineRepository $airlinesRepo)
{
$this->airlineRepo = $airlinesRepo;
}
/**
* Display a listing of the Airlines.
*/
public function index(Request $request)
{
$this->airlineRepo->pushCriteria(new RequestCriteria($request));
$airlines = $this->airlineRepo->all();
return view('admin.airlines.index')
->with('airlines', $airlines);
}
/**
* Show the form for creating a new Airlines.
*/
public function create()
{
return view('admin.airlines.create');
}
/**
* Store a newly created Airlines in storage.
*/
public function store(CreateAirlineRequest $request)
{
$input = $request->all();
$airlines = $this->airlineRepo->create($input);
Flash::success('Airlines saved successfully.');
return redirect(route('admin.airlines.index'));
}
/**
* Display the specified Airlines.
*
* @param int $id
*
* @return mixed
*/
public function show($id)
{
$airlines = $this->airlineRepo->findWithoutFail($id);
if (empty($airlines)) {
Flash::error('Airlines not found');
return redirect(route('admin.airlines.index'));
}
return view('admin.airlines.show')->with('airlines', $airlines);
}
/**
* Show the form for editing the specified Airlines.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
{
$airline = $this->airlineRepo->findWithoutFail($id);
if (empty($airline)) {
Flash::error('Airline not found');
return redirect(route('admin.airlines.index'));
}
return view('admin.airlines.edit')->with('airline', $airline);
}
/**
* Update the specified Airlines in storage.
*
* @param int $id
* @param UpdateAirlineRequest $request
*
* @return Response
*/
public function update($id, UpdateAirlineRequest $request)
{
$airlines = $this->airlineRepo->findWithoutFail($id);
if (empty($airlines)) {
Flash::error('Airlines not found');
return redirect(route('admin.airlines.index'));
}
$airlines = $this->airlineRepo->update($request->all(), $id);
Flash::success('Airlines updated successfully.');
return redirect(route('admin.airlines.index'));
}
/**
* Remove the specified Airlines from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
{
$airlines = $this->airlineRepo->findWithoutFail($id);
if (empty($airlines)) {
Flash::error('Airlines not found');
return redirect(route('admin.airlines.index'));
}
$this->airlineRepo->delete($id);
Flash::success('Airlines deleted successfully.');
return redirect(route('admin.airlines.index'));
}
}