-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add airports table and #7 integrate permissions
- Loading branch information
Showing
25 changed files
with
640 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,3 @@ DB_USERNAME= | |
DB_PASSWORD= | ||
|
||
CACHE_DRIVER=array | ||
SESSION_DRIVER=array | ||
QUEUE_DRIVER=sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Http\Requests; | ||
use App\Http\Requests\CreateAirportRequest; | ||
use App\Http\Requests\UpdateAirportRequest; | ||
use App\Repositories\AirportRepository; | ||
use App\Http\Controllers\AppBaseController as InfyOmBaseController; | ||
use Illuminate\Http\Request; | ||
use Flash; | ||
use Prettus\Repository\Criteria\RequestCriteria; | ||
use Response; | ||
|
||
class AirportController extends InfyOmBaseController | ||
{ | ||
/** @var AirportRepository */ | ||
private $airportRepository; | ||
|
||
public function __construct(AirportRepository $airportRepo) | ||
{ | ||
$this->airportRepository = $airportRepo; | ||
} | ||
|
||
/** | ||
* Display a listing of the Airport. | ||
* | ||
* @param Request $request | ||
* @return Response | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
$this->airportRepository->pushCriteria(new RequestCriteria($request)); | ||
$airports = $this->airportRepository->all(); | ||
|
||
return view('admin.airports.index') | ||
->with('airports', $airports); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new Airport. | ||
* | ||
* @return Response | ||
*/ | ||
public function create() | ||
{ | ||
return view('admin.airports.create'); | ||
} | ||
|
||
/** | ||
* Store a newly created Airport in storage. | ||
* | ||
* @param CreateAirportRequest $request | ||
* | ||
* @return Response | ||
*/ | ||
public function store(CreateAirportRequest $request) | ||
{ | ||
$input = $request->all(); | ||
|
||
$airport = $this->airportRepository->create($input); | ||
|
||
Flash::success('Airport saved successfully.'); | ||
|
||
return redirect(route('admin.airports.index')); | ||
} | ||
|
||
/** | ||
* Display the specified Airport. | ||
* | ||
* @param int $id | ||
* | ||
* @return Response | ||
*/ | ||
public function show($id) | ||
{ | ||
$airport = $this->airportRepository->findWithoutFail($id); | ||
|
||
if (empty($airport)) { | ||
Flash::error('Airport not found'); | ||
|
||
return redirect(route('admin.airports.index')); | ||
} | ||
|
||
return view('admin.airports.show')->with('airport', $airport); | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified Airport. | ||
* | ||
* @param int $id | ||
* | ||
* @return Response | ||
*/ | ||
public function edit($id) | ||
{ | ||
$airport = $this->airportRepository->findWithoutFail($id); | ||
|
||
if (empty($airport)) { | ||
Flash::error('Airport not found'); | ||
|
||
return redirect(route('admin.airports.index')); | ||
} | ||
|
||
return view('admin.airports.edit')->with('airport', $airport); | ||
} | ||
|
||
/** | ||
* Update the specified Airport in storage. | ||
* | ||
* @param int $id | ||
* @param UpdateAirportRequest $request | ||
* | ||
* @return Response | ||
*/ | ||
public function update($id, UpdateAirportRequest $request) | ||
{ | ||
$airport = $this->airportRepository->findWithoutFail($id); | ||
|
||
if (empty($airport)) { | ||
Flash::error('Airport not found'); | ||
|
||
return redirect(route('admin.airports.index')); | ||
} | ||
|
||
$airport = $this->airportRepository->update($request->all(), $id); | ||
|
||
Flash::success('Airport updated successfully.'); | ||
|
||
return redirect(route('admin.airports.index')); | ||
} | ||
|
||
/** | ||
* Remove the specified Airport from storage. | ||
* | ||
* @param int $id | ||
* | ||
* @return Response | ||
*/ | ||
public function destroy($id) | ||
{ | ||
$airport = $this->airportRepository->findWithoutFail($id); | ||
|
||
if (empty($airport)) { | ||
Flash::error('Airport not found'); | ||
|
||
return redirect(route('admin.airports.index')); | ||
} | ||
|
||
$this->airportRepository->delete($id); | ||
|
||
Flash::success('Airport deleted successfully.'); | ||
|
||
return redirect(route('admin.airports.index')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Http\Requests\Request; | ||
use App\Models\Airport; | ||
|
||
class CreateAirportRequest extends Request | ||
{ | ||
|
||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return Airport::$rules; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Http\Requests\Request; | ||
use App\Models\Airport; | ||
|
||
class UpdateAirportRequest extends Request | ||
{ | ||
|
||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return Airport::$rules; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Eloquent as Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
/** | ||
* Class Airport | ||
* @package App\Models | ||
*/ | ||
class Airport extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
public $table = 'airports'; | ||
|
||
|
||
protected $dates = ['deleted_at']; | ||
|
||
|
||
public $fillable = [ | ||
'icao' | ||
]; | ||
|
||
/** | ||
* The attributes that should be casted to native types. | ||
* | ||
* @var array | ||
*/ | ||
protected $casts = [ | ||
|
||
]; | ||
|
||
/** | ||
* Validation rules | ||
* | ||
* @var array | ||
*/ | ||
public static $rules = [ | ||
'icao' => 'required' | ||
]; | ||
|
||
public function save(array $options = []) | ||
{ | ||
if(in_array('icao', $options)) { | ||
$options['icao'] = strtoupper($options['icao']); | ||
} | ||
|
||
return parent::save($options); | ||
} | ||
} |
Oops, something went wrong.