From b5c41626c52147ec6bb802d4838d42c28bb4ae63 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Wed, 21 Jun 2017 12:10:25 -0500 Subject: [PATCH] #23 initial scaffolding for rankings --- Makefile | 1 - app/Http/Controllers/RankingController.php | 156 ++++++++++++++++++ app/Http/Requests/CreateRankingRequest.php | 30 ++++ app/Http/Requests/UpdateRankingRequest.php | 30 ++++ app/Models/Ranking.php | 42 +++++ app/Repositories/RankingRepository.php | 24 +++ ...017_06_21_165410_create_rankings_table.php | 36 ++++ gulpfile.js | 5 + .../views/admin/rankings/create.blade.php | 24 +++ resources/views/admin/rankings/edit.blade.php | 23 +++ .../views/admin/rankings/fields.blade.php | 35 ++++ .../views/admin/rankings/index.blade.php | 23 +++ resources/views/admin/rankings/show.blade.php | 19 +++ .../admin/rankings/show_fields.blade.php | 48 ++++++ .../views/admin/rankings/table.blade.php | 30 ++++ routes/web.php | 10 ++ 16 files changed, 535 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/RankingController.php create mode 100644 app/Http/Requests/CreateRankingRequest.php create mode 100644 app/Http/Requests/UpdateRankingRequest.php create mode 100644 app/Models/Ranking.php create mode 100644 app/Repositories/RankingRepository.php create mode 100644 database/migrations/2017_06_21_165410_create_rankings_table.php create mode 100644 resources/views/admin/rankings/create.blade.php create mode 100644 resources/views/admin/rankings/edit.blade.php create mode 100644 resources/views/admin/rankings/fields.blade.php create mode 100644 resources/views/admin/rankings/index.blade.php create mode 100644 resources/views/admin/rankings/show.blade.php create mode 100644 resources/views/admin/rankings/show_fields.blade.php create mode 100644 resources/views/admin/rankings/table.blade.php diff --git a/Makefile b/Makefile index 0ba982c6..1b3fe024 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,6 @@ test: vendor/bin/phpunit --testdox tests schema: - #php artisan infyom:scaffold Airlines --fieldsFile=database/schema/airlines.json #php artisan infyom:scaffold Aircraft --fieldsFile=database/schema/aircraft.json echo "" diff --git a/app/Http/Controllers/RankingController.php b/app/Http/Controllers/RankingController.php new file mode 100644 index 00000000..e534a3de --- /dev/null +++ b/app/Http/Controllers/RankingController.php @@ -0,0 +1,156 @@ +rankingRepository = $rankingRepo; + } + + /** + * Display a listing of the Ranking. + * + * @param Request $request + * @return Response + */ + public function index(Request $request) + { + $this->rankingRepository->pushCriteria(new RequestCriteria($request)); + $rankings = $this->rankingRepository->all(); + + return view('admin.rankings.index') + ->with('rankings', $rankings); + } + + /** + * Show the form for creating a new Ranking. + * + * @return Response + */ + public function create() + { + return view('admin.rankings.create'); + } + + /** + * Store a newly created Ranking in storage. + * + * @param CreateRankingRequest $request + * + * @return Response + */ + public function store(CreateRankingRequest $request) + { + $input = $request->all(); + + $ranking = $this->rankingRepository->create($input); + + Flash::success('Ranking saved successfully.'); + + return redirect(route('admin.rankings.index')); + } + + /** + * Display the specified Ranking. + * + * @param int $id + * + * @return Response + */ + public function show($id) + { + $ranking = $this->rankingRepository->findWithoutFail($id); + + if (empty($ranking)) { + Flash::error('Ranking not found'); + + return redirect(route('admin.rankings.index')); + } + + return view('admin.rankings.show')->with('ranking', $ranking); + } + + /** + * Show the form for editing the specified Ranking. + * + * @param int $id + * + * @return Response + */ + public function edit($id) + { + $ranking = $this->rankingRepository->findWithoutFail($id); + + if (empty($ranking)) { + Flash::error('Ranking not found'); + + return redirect(route('admin.rankings.index')); + } + + return view('admin.rankings.edit')->with('ranking', $ranking); + } + + /** + * Update the specified Ranking in storage. + * + * @param int $id + * @param UpdateRankingRequest $request + * + * @return Response + */ + public function update($id, UpdateRankingRequest $request) + { + $ranking = $this->rankingRepository->findWithoutFail($id); + + if (empty($ranking)) { + Flash::error('Ranking not found'); + + return redirect(route('admin.rankings.index')); + } + + $ranking = $this->rankingRepository->update($request->all(), $id); + + Flash::success('Ranking updated successfully.'); + + return redirect(route('admin.rankings.index')); + } + + /** + * Remove the specified Ranking from storage. + * + * @param int $id + * + * @return Response + */ + public function destroy($id) + { + $ranking = $this->rankingRepository->findWithoutFail($id); + + if (empty($ranking)) { + Flash::error('Ranking not found'); + + return redirect(route('admin.rankings.index')); + } + + $this->rankingRepository->delete($id); + + Flash::success('Ranking deleted successfully.'); + + return redirect(route('admin.rankings.index')); + } +} diff --git a/app/Http/Requests/CreateRankingRequest.php b/app/Http/Requests/CreateRankingRequest.php new file mode 100644 index 00000000..b9cb8a40 --- /dev/null +++ b/app/Http/Requests/CreateRankingRequest.php @@ -0,0 +1,30 @@ + 'string', + 'hours' => 'integer' + ]; + + /** + * Validation rules + * + * @var array + */ + public static $rules = [ + + ]; +} diff --git a/app/Repositories/RankingRepository.php b/app/Repositories/RankingRepository.php new file mode 100644 index 00000000..a6d649da --- /dev/null +++ b/app/Repositories/RankingRepository.php @@ -0,0 +1,24 @@ +increments('id'); + $table->string('name'); + $table->integer('hours')->default(0); + $table->bool('auto_approval_acars')->default(false); + $table->bool('auto_approval_manual')->default(false); + $table->bool('auto_promote')->default(true); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('rankings'); + } +} diff --git a/gulpfile.js b/gulpfile.js index 04d503d8..a1ae8d4c 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -17,3 +17,8 @@ elixir(mix => { mix.sass('app.scss') .webpack('app.js'); }); + + +gulp.task('reset', function() { + exec('php artisan migrate:refresh --seed --seeder DevelopmentSeeder'); +}); diff --git a/resources/views/admin/rankings/create.blade.php b/resources/views/admin/rankings/create.blade.php new file mode 100644 index 00000000..62331897 --- /dev/null +++ b/resources/views/admin/rankings/create.blade.php @@ -0,0 +1,24 @@ +@extends('layouts.app') + +@section('content') +
+

+ $MODEL_NAME_HUMAN$ +

+
+
+ @include('adminlte-templates::common.errors') +
+ +
+
+ {!! Form::open(['route' => 'admin.rankings.store']) !!} + + @include('admin.rankings.fields') + + {!! Form::close() !!} +
+
+
+
+@endsection diff --git a/resources/views/admin/rankings/edit.blade.php b/resources/views/admin/rankings/edit.blade.php new file mode 100644 index 00000000..b4f2ec7d --- /dev/null +++ b/resources/views/admin/rankings/edit.blade.php @@ -0,0 +1,23 @@ +@extends('layouts.app') + +@section('content') +
+

+ $MODEL_NAME_HUMAN$ +

+
+
+ @include('adminlte-templates::common.errors') +
+
+
+ {!! Form::model($ranking, ['route' => ['admin.rankings.update', $ranking->$PRIMARY_KEY_NAME$], 'method' => 'patch']) !!} + + @include('admin.rankings.fields') + + {!! Form::close() !!} +
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/rankings/fields.blade.php b/resources/views/admin/rankings/fields.blade.php new file mode 100644 index 00000000..a817c1c8 --- /dev/null +++ b/resources/views/admin/rankings/fields.blade.php @@ -0,0 +1,35 @@ + +
+ {!! Form::label('name', 'Name:') !!} + {!! Form::text('name', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::label('hours', 'Hours:') !!} + {!! Form::text('hours', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::label('auto_approve_acars', 'Auto Approve Acars:') !!} + {!! Form::text('auto_approve_acars', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::label('auto_approve_manual', 'Auto Approve Manual:') !!} + {!! Form::text('auto_approve_manual', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::label('auto_promote', 'Auto Promote:') !!} + {!! Form::text('auto_promote', null, ['class' => 'form-control']) !!} +
+ + +
+ {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} + Cancel +
diff --git a/resources/views/admin/rankings/index.blade.php b/resources/views/admin/rankings/index.blade.php new file mode 100644 index 00000000..2be0eb9f --- /dev/null +++ b/resources/views/admin/rankings/index.blade.php @@ -0,0 +1,23 @@ +@extends('layouts.app') + +@section('content') +
+

$MODEL_NAME_PLURAL_HUMAN$

+

+ Add New +

+
+
+
+ + @include('flash::message') + +
+
+
+ @include('admin.rankings.table') +
+
+
+@endsection + diff --git a/resources/views/admin/rankings/show.blade.php b/resources/views/admin/rankings/show.blade.php new file mode 100644 index 00000000..78b0c8d9 --- /dev/null +++ b/resources/views/admin/rankings/show.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.app') + +@section('content') +
+

+ $MODEL_NAME_HUMAN$ +

+
+
+
+
+
+ @include('admin.rankings.show_fields') + Back +
+
+
+
+@endsection diff --git a/resources/views/admin/rankings/show_fields.blade.php b/resources/views/admin/rankings/show_fields.blade.php new file mode 100644 index 00000000..252e01ae --- /dev/null +++ b/resources/views/admin/rankings/show_fields.blade.php @@ -0,0 +1,48 @@ + +
+ {!! Form::label('id', 'Id:') !!} +

{!! $ranking->id !!}

+
+ + +
+ {!! Form::label('name', 'Name:') !!} +

{!! $ranking->name !!}

+
+ + +
+ {!! Form::label('hours', 'Hours:') !!} +

{!! $ranking->hours !!}

+
+ + +
+ {!! Form::label('auto_approve_acars', 'Auto Approve Acars:') !!} +

{!! $ranking->auto_approve_acars !!}

+
+ + +
+ {!! Form::label('auto_approve_manual', 'Auto Approve Manual:') !!} +

{!! $ranking->auto_approve_manual !!}

+
+ + +
+ {!! Form::label('auto_promote', 'Auto Promote:') !!} +

{!! $ranking->auto_promote !!}

+
+ + +
+ {!! Form::label('created_at', 'Created At:') !!} +

{!! $ranking->created_at !!}

+
+ + +
+ {!! Form::label('updated_at', 'Updated At:') !!} +

{!! $ranking->updated_at !!}

+
+ diff --git a/resources/views/admin/rankings/table.blade.php b/resources/views/admin/rankings/table.blade.php new file mode 100644 index 00000000..fe0abf1c --- /dev/null +++ b/resources/views/admin/rankings/table.blade.php @@ -0,0 +1,30 @@ + + + + + + + + + + + @foreach($rankings as $ranking) + + + + + + + + + @endforeach + +
NameHoursAuto Approve AcarsAuto Approve ManualAuto PromoteAction
{!! $ranking->name !!}{!! $ranking->hours !!}{!! $ranking->auto_approve_acars !!}{!! $ranking->auto_approve_manual !!}{!! $ranking->auto_promote !!} + {!! Form::open(['route' => ['admin.rankings.destroy', $ranking->$PRIMARY_KEY_NAME$], 'method' => 'delete']) !!} +
+ + + {!! Form::button('', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!} +
+ {!! Form::close() !!} +
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index aae2f422..1425109a 100755 --- a/routes/web.php +++ b/routes/web.php @@ -17,3 +17,13 @@ Route::group([ Auth::routes(); require base_path('routes/admin.php'); + + +Route::get('admin/rankings', ['as'=> 'admin.rankings.index', 'uses' => 'RankingController@index']); +Route::post('admin/rankings', ['as'=> 'admin.rankings.store', 'uses' => 'RankingController@store']); +Route::get('admin/rankings/create', ['as'=> 'admin.rankings.create', 'uses' => 'RankingController@create']); +Route::put('admin/rankings/{rankings}', ['as'=> 'admin.rankings.update', 'uses' => 'RankingController@update']); +Route::patch('admin/rankings/{rankings}', ['as'=> 'admin.rankings.update', 'uses' => 'RankingController@update']); +Route::delete('admin/rankings/{rankings}', ['as'=> 'admin.rankings.destroy', 'uses' => 'RankingController@destroy']); +Route::get('admin/rankings/{rankings}', ['as'=> 'admin.rankings.show', 'uses' => 'RankingController@show']); +Route::get('admin/rankings/{rankings}/edit', ['as'=> 'admin.rankings.edit', 'uses' => 'RankingController@edit']);