srp module
This commit is contained in:
54
app/Http/Controllers/SRP/SRPAdminController.php
Normal file
54
app/Http/Controllers/SRP/SRPAdminController.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SRP;
|
||||
|
||||
//Laravel Libraries
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Auth;
|
||||
|
||||
//User Libraries
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\Ship;
|
||||
|
||||
class SRPAdminController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:User');
|
||||
$this->middleware('permission:srp.admin');
|
||||
}
|
||||
|
||||
public function displaySRPRequests() {
|
||||
$this->middleware('permission:srp.admin');
|
||||
|
||||
$requests = Ship::where(['approved' => 'Not Paid'])->get();
|
||||
|
||||
return view('srp.admin.process')->with('requests', $request);
|
||||
}
|
||||
|
||||
public function processSRPRequest() {
|
||||
$this->middleware('permission:srp.admin');
|
||||
|
||||
$this->validate($request, [
|
||||
'id' => 'required',
|
||||
'approved' => 'required',
|
||||
'paid_value' => 'required',
|
||||
]);
|
||||
|
||||
$srp = SRPShip::where(['id' => $id])->update([
|
||||
'approved' => $request->approved,
|
||||
'paid_value' => $request->paid_value,
|
||||
'paid_by_id' => auth()->user()->character_id,
|
||||
'paid_by_name' => auth()->user()->name,
|
||||
]);
|
||||
|
||||
if($request->approved == 'Yes') {
|
||||
return redirect('/srp/admin/display')->with('success', 'SRP Marked as Paid');
|
||||
} else {
|
||||
return redirect('/srp/admin/display')->with('error', 'SRP Request Denied.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,22 +11,20 @@ use Auth;
|
||||
//User Libraries
|
||||
|
||||
//Models
|
||||
use App\Models\SRP\Fleet;
|
||||
use App\Models\SRP\FleetCommander;
|
||||
use App\Models\SRP\Ship;
|
||||
use App\Models\SRP\SRPShip;
|
||||
|
||||
class SRPController extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middelware('role:User');
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
public function displaySrpForm() {
|
||||
return view('srp.srpform');
|
||||
}
|
||||
|
||||
public function storeSRPFile() {
|
||||
public function storeSRPFile(Request $request) {
|
||||
$this->validate($request, [
|
||||
'FC' => 'required',
|
||||
'FleetType' => 'required',
|
||||
@@ -35,16 +33,22 @@ class SRPController extends Controller
|
||||
'ShipType' => 'required',
|
||||
]);
|
||||
|
||||
$fc = $request->FC;
|
||||
$fleetType = $request->FleetType;
|
||||
$zKill = $request->zKillboard;
|
||||
$loss = $request->LossValue;
|
||||
$ship = $request->ShipType;
|
||||
//See if the FC Name ties to a user on the services site
|
||||
$fcId = User::where(['name' => $request->fc])->get(['character_id']);
|
||||
|
||||
$ship = new SRPShip;
|
||||
$ship->character_id = auth()->user()->character_id;
|
||||
$ship->character_name = auth()->user()->name;
|
||||
$ship->fleet_commander_name = $request->fc;
|
||||
if($fcId[0] != null) {
|
||||
$ship->fleet_commander_id = $fcId;
|
||||
}
|
||||
$ship->zkillboard = $request->zKillboard;
|
||||
$ship->ship_type = $request->ShipType;
|
||||
$ship->loss_value = $request->LossValue;
|
||||
$ship->save();
|
||||
|
||||
return redirect('/srpform')->with('success', 'SRP Form Submitted.');
|
||||
}
|
||||
|
||||
public function displaySRPRequests() {
|
||||
$this->middleware('permission:SRP');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fleet extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'srp_fleet';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'fleet_id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
//Fillable Items
|
||||
protected $fillable = [
|
||||
'fleet_id',
|
||||
'fleet_name',
|
||||
'fleet_commander',
|
||||
'fleet_commander_id',
|
||||
'fleet_type',
|
||||
'fleet_description',
|
||||
];
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace App\Models\SRP;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ship extends Model
|
||||
class SRPShip extends Model
|
||||
{
|
||||
//Table Name
|
||||
protected $table = 'srp_ships';
|
||||
@@ -17,9 +17,17 @@ class Ship extends Model
|
||||
|
||||
//Fillable Items
|
||||
protected $fillable = [
|
||||
'ship_type',
|
||||
'character_id',
|
||||
'character_name',
|
||||
'fleet_commander_name',
|
||||
'fleet_commander_id',
|
||||
'zkillboard',
|
||||
'ship_type',
|
||||
'loss_value',
|
||||
'notes',
|
||||
'approved',
|
||||
'paid_value',
|
||||
'paid_by_id',
|
||||
'paid_by_name',
|
||||
];
|
||||
}
|
||||
@@ -16,22 +16,19 @@ class CreateSrpTables extends Migration
|
||||
if(!Schema::hasTable('srp_ships')) {
|
||||
Schema::create('srp_ships', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('ship_type');
|
||||
$table->string('character_id');
|
||||
$table->string('zkillboard');
|
||||
$table->string('loss_values');
|
||||
$table->text('notes');
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('srp_fleets')) {
|
||||
Schema::create('srp_fleets', function(Blueprint $table) {
|
||||
$table->increments('fleet_id');
|
||||
$table->string('fleet_name');
|
||||
$table->string('fleet_commander');
|
||||
$table->string('character_id')->default('N/A');
|
||||
$table->string('character_name');
|
||||
$table->string('fleet_commander_id');
|
||||
$table->string('fleet_type');
|
||||
$table->string('fleet_description');
|
||||
$table->string('fleet_commander_name');
|
||||
$table->string('zkillboard');
|
||||
$table->string('ship_type');
|
||||
$table->decimal('loss_value', 20, 2);
|
||||
$table->string('approved')->default('Not Paid');
|
||||
$table->decimal('paid_value', 20, 2)->default(0.00);
|
||||
$table->string('notes')->nullable();
|
||||
$table->string('paid_by_id')->nullable();
|
||||
$table->string('paid_by_name')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -44,6 +41,5 @@ class CreateSrpTables extends Migration
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('srp_ships');
|
||||
Schema::dropIfExists('srp_fleets');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user