#23 add rankings

This commit is contained in:
Nabeel Shahzad 2017-06-21 20:18:01 -05:00
parent 363d463833
commit 5b920151b8
12 changed files with 78 additions and 104 deletions

View File

@ -3,6 +3,6 @@
<component name="XtextAutoBuilderState">
<installedLanguages>xtend;xtext</installedLanguages>
<index>rO0ABXNyADtvcmcuZWNsaXBzZS54dGV4dC5yZXNvdXJjZS5pbXBsLkNodW5rZWRSZXNvdXJjZURlc2NyaXB0aW9uc4nX+GBmyGixDAAAeHB3BAAAAAB4</index>
<module2generated>rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAAAeA==</module2generated>
<module2generated>rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAB3CAAAABAAAAAAeA==</module2generated>
</component>
</project>

View File

@ -2,8 +2,8 @@
namespace App\Http\Controllers\Admin;
use App\Http\Requests\CreateRankingRequest;
use App\Http\Requests\UpdateRankingRequest;
use App\Http\Requests\CreateRankRequest;
use App\Http\Requests\UpdateRankRequest;
use App\Repositories\RankRepository;
use App\Http\Controllers\AppBaseController as InfyOmBaseController;
use Illuminate\Http\Request;
@ -49,18 +49,20 @@ class RankController extends BaseController
/**
* Store a newly created Ranking in storage.
*
* @param CreateRankingRequest $request
* @param CreateRankRequest $request
*
* @return Response
*/
public function store(CreateRankingRequest $request)
public function store(Request $request)
{
$input = $request->all();
$rank = $this->rankRepository->create($input);
$model = $this->rankRepository->create($input);
Flash::success('Ranking saved successfully.');
return redirect(route('admin.ranks.index'));
$ranks = $this->rankRepository->all();
return view('admin.ranks.table')
->with('ranks', $ranks);
}
/**
@ -105,11 +107,11 @@ class RankController extends BaseController
* Update the specified Ranking in storage.
*
* @param int $id
* @param UpdateRankingRequest $request
* @param UpdateRankRequest $request
*
* @return Response
*/
public function update($id, UpdateRankingRequest $request)
public function update($id, UpdateRankRequest $request)
{
$rank = $this->rankRepository->findWithoutFail($id);

View File

@ -5,7 +5,7 @@ namespace App\Http\Requests;
use App\Http\Requests\Request;
use App\Models\Rank;
class CreateRankingRequest extends Request
class CreateRankRequest extends Request
{
/**

View File

@ -5,7 +5,7 @@ namespace App\Http\Requests;
use App\Http\Requests\Request;
use App\Models\Rank;
class UpdateRankingRequest extends Request
class UpdateRankRequest extends Request
{
/**

View File

@ -28,7 +28,10 @@ class Rank extends Model
*/
protected $casts = [
'name' => 'string',
'hours' => 'integer'
'hours' => 'integer',
'auto_approve_acars' => 'boolean',
'auto_approve_manual' => 'boolean',
'auto_promote' => 'boolean',
];
/**
@ -37,6 +40,6 @@ class Rank extends Model
* @var array
*/
public static $rules = [
'name' => 'unique',
];
}

62
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "aceb14d1910187737873cd904aec5630",
"content-hash": "abd8dd8b12ea7f677c5bf93da12e0948",
"packages": [
{
"name": "anlutro/l4-settings",
@ -1553,16 +1553,16 @@
},
{
"name": "maatwebsite/excel",
"version": "2.1.17",
"version": "2.1.18",
"source": {
"type": "git",
"url": "https://github.com/Maatwebsite/Laravel-Excel.git",
"reference": "14d5abf8e20563c80dd074fd7c8cf1c05bf51f1d"
"reference": "a43db59e621e8e8d72321e885d1610509cc7b096"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/14d5abf8e20563c80dd074fd7c8cf1c05bf51f1d",
"reference": "14d5abf8e20563c80dd074fd7c8cf1c05bf51f1d",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/a43db59e621e8e8d72321e885d1610509cc7b096",
"reference": "a43db59e621e8e8d72321e885d1610509cc7b096",
"shasum": ""
},
"require": {
@ -1589,6 +1589,16 @@
"illuminate/view": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Maatwebsite\\Excel\\ExcelServiceProvider"
],
"aliases": {
"Excel": "Maatwebsite\\Excel\\Facades\\Excel"
}
}
},
"autoload": {
"classmap": [
"src/Maatwebsite/Excel"
@ -1617,7 +1627,7 @@
"import",
"laravel"
],
"time": "2017-04-04T18:28:12+00:00"
"time": "2017-06-21T20:39:34+00:00"
},
{
"name": "monolog/monolog",
@ -4238,46 +4248,6 @@
}
],
"packages-dev": [
{
"name": "bpocallaghan/generators",
"version": "4.0.9",
"source": {
"type": "git",
"url": "https://github.com/bpocallaghan/generators.git",
"reference": "53b7e42bcda2409996bb611e3893335d42509830"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bpocallaghan/generators/zipball/53b7e42bcda2409996bb611e3893335d42509830",
"reference": "53b7e42bcda2409996bb611e3893335d42509830",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Bpocallaghan\\Generators\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ben-Piet O'Callaghan",
"email": "bpocallaghan@gmail.com"
}
],
"description": "Custom Laravel 5 File Generators with config and publishable stubs.",
"keywords": [
"generators",
"laravel"
],
"time": "2017-05-15T11:04:00+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.0.5",

View File

@ -17,10 +17,12 @@ class CreateRanksTable extends Migration
$table->increments('id');
$table->string('name');
$table->integer('hours')->default(0);
$table->boolean('auto_approval_acars')->default(false);
$table->boolean('auto_approval_manual')->default(false);
$table->boolean('auto_approve_acars')->default(false);
$table->boolean('auto_approve_manual')->default(false);
$table->boolean('auto_promote')->default(true);
$table->timestamps();
$table->unique('name');
});
Schema::create('flight_rank', function(Blueprint $table) {

View File

@ -3,7 +3,6 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/vendor/bpocallaghan/generators" />
<excludeFolder url="file://$MODULE_DIR$/vendor/dompdf/dompdf" />
<excludeFolder url="file://$MODULE_DIR$/vendor/jeremeamia/SuperClosure" />
<excludeFolder url="file://$MODULE_DIR$/vendor/league/fractal" />
@ -32,7 +31,6 @@
<library name="PHP" type="php">
<CLASSES>
<root url="file://$APPLICATION_HOME_DIR$/bin" />
<root url="file://$MODULE_DIR$/vendor/bpocallaghan/generators" />
<root url="file://$MODULE_DIR$/vendor/dompdf/dompdf" />
<root url="file://$MODULE_DIR$/vendor/jeremeamia/SuperClosure" />
<root url="file://$MODULE_DIR$/vendor/league/fractal" />
@ -48,7 +46,6 @@
<JAVADOC />
<SOURCES>
<root url="file://$APPLICATION_HOME_DIR$/bin" />
<root url="file://$MODULE_DIR$/vendor/bpocallaghan/generators" />
<root url="file://$MODULE_DIR$/vendor/dompdf/dompdf" />
<root url="file://$MODULE_DIR$/vendor/jeremeamia/SuperClosure" />
<root url="file://$MODULE_DIR$/vendor/league/fractal" />

View File

@ -7,7 +7,7 @@
<div class="box-body">
<div class="row">
{!! Form::open(['route' => 'admin.ranks.store', 'class' => 'add_rank']) !!}
{!! Form::open(['route' => 'admin.ranks.store', 'class' => 'add_rank', 'method'=>'POST']) !!}
@include('admin.ranks.fields')

View File

@ -19,12 +19,11 @@
</div>
</div>
<div id="create_rank_wrapper">
@include('admin.ranks.create')
</div>
@include('admin.ranks.create')
</div>
@endsection
@section('scripts')
<script type="text/javascript">
$(document).ready(function () {
/*$(".ac-fare-dropdown").select2();
@ -45,7 +44,7 @@
$(document).on('submit', 'form.add_rank', function (event) {
event.preventDefault();
$.pjax.submit(event, '#create_rank_wrapper', {push: false});
$.pjax.submit(event, '#ranks_table_wrapper', {push: false});
});
});
</script>

View File

@ -1,33 +1,35 @@
<table class="table table-responsive" id="ranks-table">
<thead>
<th>Name</th>
<th>Hours</th>
<th>Auto Approve Acars</th>
<th>Auto Approve Manual</th>
<th>Auto Promote</th>
<th colspan="3">Action</th>
</thead>
<tbody>
@foreach($ranks as $rank)
<tr>
<td>{!! $rank->name !!}</td>
<td>{!! $rank->hours !!}</td>
<td>{!! $rank->auto_approve_acars !!}</td>
<td>{!! $rank->auto_approve_manual !!}</td>
<td>{!! $rank->auto_promote !!}</td>
<td>
{!! Form::open(['route' => ['admin.ranks.destroy', $rank->id], 'method' => 'delete']) !!}
<div class='btn-group'>
<a href="{!! route('admin.ranks.show', [$rank->id]) !!}"
class='btn btn-default btn-xs'><i
class="glyphicon glyphicon-eye-open"></i></a>
<a href="{!! route('admin.ranks.edit', [$rank->id]) !!}"
class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
</div>
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>
<div id="ranks_table_wrapper">
<table class="table table-responsive">
<thead>
<th>Name</th>
<th>Hours</th>
<th>Auto Approve Acars</th>
<th>Auto Approve Manual</th>
<th>Auto Promote</th>
<th colspan="3">Action</th>
</thead>
<tbody>
@foreach($ranks as $rank)
<tr>
<td>{!! $rank->name !!}</td>
<td>{!! $rank->hours !!}</td>
<td>{!! $rank->auto_approve_acars !!}</td>
<td>{!! $rank->auto_approve_manual !!}</td>
<td>{!! $rank->auto_promote !!}</td>
<td>
{!! Form::open(['route' => ['admin.ranks.destroy', $rank->id], 'method' => 'delete']) !!}
<div class='btn-group'>
<a href="{!! route('admin.ranks.show', [$rank->id]) !!}"
class='btn btn-default btn-xs'><i
class="glyphicon glyphicon-eye-open"></i></a>
<a href="{!! route('admin.ranks.edit', [$rank->id]) !!}"
class='btn btn-default btn-xs'><i class="glyphicon glyphicon-edit"></i></a>
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure?')"]) !!}
</div>
{!! Form::close() !!}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>

View File

@ -3,7 +3,6 @@
Route::get('/', 'HomeController@index');
Route::get('/home', 'HomeController@index');
/**
* These are only visible to a logged in user
*/