srp admin controller
This commit is contained in:
@@ -27,15 +27,48 @@ class SRPAdminController extends Controller
|
||||
public function displaySRPRequests() {
|
||||
$this->middleware('permission:srp.admin');
|
||||
|
||||
$requests = null;
|
||||
$requests = array();
|
||||
|
||||
$shipTypes = SrpShipType::all();
|
||||
$fleetTypes = SrpFleetType::all();
|
||||
$payouts = SrpPayout::all();
|
||||
|
||||
$count = SRPShip::where(['approved' => 'Under Review'])->count();
|
||||
if($count === 0) {
|
||||
$requests = null;
|
||||
} else {
|
||||
$requests = SRPShip::where(['approved' => 'Under Review'])->get();
|
||||
$reqs = SRPShip::where(['approved' => 'Under Review'])->get()->toArray();
|
||||
foreach($reqs as $r) {
|
||||
$temp['created_at'] = $r['created_at'];
|
||||
$temp['character_name'] = $r['character_name'];
|
||||
$temp['fleet_commander_name'] = $r['fleet_commander_name'];
|
||||
$temp['zkillboard'] = $r['zkillboard'];
|
||||
$temp['loss_value'] = $r['loss_value'];
|
||||
//Get the ship type
|
||||
foreach($shipTypes as $s) {
|
||||
if($r['ship_type'] == $s->code) {
|
||||
$temp['ship_type'] = $s->description;
|
||||
}
|
||||
}
|
||||
//Get the fleet type
|
||||
foreach($fleetTypes as $f) {
|
||||
if($r['fleet_type'] == $f->code) {
|
||||
$temp['fleet_type'] = $f->description;
|
||||
}
|
||||
}
|
||||
//Calculate the recommended srp amount
|
||||
foreach($payouts as $p) {
|
||||
if($r['ship_type'] == $p->code) {
|
||||
$temp['actual_srp'] = $temp['loss_value'] * ($p->payout / 100.00 );
|
||||
}
|
||||
}
|
||||
|
||||
array_push($requests, $temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return view('srp.admin.process')->with('requests', $requests);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ class SRPController extends Controller
|
||||
$ship->fleet_commander_id = $fcId[0]->character_id;
|
||||
}
|
||||
$ship->zkillboard = $request->zKillboard;
|
||||
$ship->fleet_type = $request->FleetType;
|
||||
$ship->ship_type = $request->ShipType;
|
||||
$ship->loss_value = $lossValue;
|
||||
$ship->save();
|
||||
|
||||
17
app/Models/SRP/SrpPayout.php
Normal file
17
app/Models/SRP/SrpPayout.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SrpPayout extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'srp_payouts';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
}
|
||||
@@ -22,6 +22,7 @@ class CreateSrpTables extends Migration
|
||||
$table->string('fleet_commander_name');
|
||||
$table->string('zkillboard');
|
||||
$table->string('ship_type');
|
||||
$table->string('fleet_type');
|
||||
$table->decimal('loss_value', 20, 2);
|
||||
$table->string('approved')->default('Under Review');
|
||||
$table->decimal('paid_value', 20, 2)->default(0.00);
|
||||
@@ -48,6 +49,14 @@ class CreateSrpTables extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('srp_payouts')) {
|
||||
Schema::create('srp_payouts', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('code');
|
||||
$table->decimal('payout', 5, 2);
|
||||
});
|
||||
}
|
||||
|
||||
DB::table('srp_fleet_types')->insert([
|
||||
'code' => 'None',
|
||||
'description' => 'None',
|
||||
@@ -122,6 +131,51 @@ class CreateSrpTables extends Migration
|
||||
'code' => 'COM',
|
||||
'description' => 'Command Ship',
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'T1FDC',
|
||||
'payout' => 75.00,
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'T1BC',
|
||||
'payout' => 60.00,
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'T2F',
|
||||
'payout' => 60.00,
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'T3D',
|
||||
'payout' => 60.00,
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'T1T2Logi',
|
||||
'payout' => 100.00,
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'RI',
|
||||
'payout' => 50.00,
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'T2C',
|
||||
'payout' => 50.00,
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'T3C',
|
||||
'payout' => 50.00,
|
||||
]);
|
||||
|
||||
DB::table('srp_payouts')->insert([
|
||||
'code' => 'COM',
|
||||
'payout' => 100.00,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,5 +188,6 @@ class CreateSrpTables extends Migration
|
||||
Schema::dropIfExists('srp_ships');
|
||||
Schema::dropIfExists('srp_ship_types');
|
||||
Schema::dropIfExists('srp_fleet_types');
|
||||
Schema::dropIfExists('srp_payouts');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
@foreach($requests as $row)
|
||||
<tr>
|
||||
<td>{{ $row['created_at'] }}</td>
|
||||
<td>{{ $row['pilot'] }}</td>
|
||||
<td>{{ $row['fc'] }}</td>
|
||||
<td><a href="{{ $row['link'] }}">zKill Link</a></td>
|
||||
<td>{{ $row['loss'] }}</td>
|
||||
<td>{{ $row['character_name'] }}</td>
|
||||
<td>{{ $row['fleet_commander_name'] }}</td>
|
||||
<td><a href="{{ $row['zkillboard'] }}">zKill Link</a></td>
|
||||
<td>{{ $row['loss_value'] }}</td>
|
||||
<td>{{ $row['ship_type'] }}</td>
|
||||
<td>{{ $row['fleet_type'] }}</td>
|
||||
<td>{{ $row['actual_srp'] }}</td>
|
||||
|
||||
Reference in New Issue
Block a user