diff --git a/app/Http/Controllers/SRP/SRPAdminController.php b/app/Http/Controllers/SRP/SRPAdminController.php index 7b2c5e59f..eb04467a8 100644 --- a/app/Http/Controllers/SRP/SRPAdminController.php +++ b/app/Http/Controllers/SRP/SRPAdminController.php @@ -12,6 +12,9 @@ use Auth; //Models use App\Models\SRP\Ship; +use App\Models\User\User; +use App\Models\SRP\SrpFleetType; +use App\Models\SRP\SrpShipType; class SRPAdminController extends Controller { diff --git a/app/Http/Controllers/SRP/SRPController.php b/app/Http/Controllers/SRP/SRPController.php index f4ccda79d..381fa3c8a 100644 --- a/app/Http/Controllers/SRP/SRPController.php +++ b/app/Http/Controllers/SRP/SRPController.php @@ -13,6 +13,8 @@ use Auth; //Models use App\Models\SRP\SRPShip; use App\Models\User\User; +use App\Models\SRP\SrpFleetType; +use App\Models\SRP\SrpShipType; class SRPController extends Controller { @@ -22,7 +24,24 @@ class SRPController extends Controller } public function displaySrpForm() { - return view('srp.srpform'); + $shipTypes = array(); + $fleetTypes = array(); + + $shipTypesTemp = SrpShipType::all(); + $fleetTypesTemp = SrpFleetType::all(); + + foreach($shipTypesTemp as $key => $value) { + $temp[$key] = $value; + array_push($shipTypes, $temp); + } + + foreach($fleetTypesTemp as $key => $value) { + $temp[$key] = $value; + array_push($fleetTypes, $temp); + } + + return view('srp.srpform')->with('fleetTypes', $fleetTypes) + ->with('shipTypes', $shipTypes); } public function storeSRPFile(Request $request) { @@ -52,7 +71,6 @@ class SRPController extends Controller $ship->zkillboard = $request->zKillboard; $ship->ship_type = $request->ShipType; $ship->loss_value = $lossValue; - dd($ship); $ship->save(); return redirect('/srpform')->with('success', 'SRP Form Submitted.'); diff --git a/app/Models/SRP/SrpFleetType.php b/app/Models/SRP/SrpFleetType.php index cfa671fff..004179681 100644 --- a/app/Models/SRP/SrpFleetType.php +++ b/app/Models/SRP/SrpFleetType.php @@ -6,5 +6,12 @@ use Illuminate\Database\Eloquent\Model; class SrpFleetType extends Model { - // + //Table Name + protected $table = 'srp_fleet_types'; + + //Primary Key + public $primaryKey = 'id'; + + //Timestamps + public $timestamps = false; } diff --git a/app/Models/SRP/SrpShipType.php b/app/Models/SRP/SrpShipType.php index 8d2e424f5..647f207bf 100644 --- a/app/Models/SRP/SrpShipType.php +++ b/app/Models/SRP/SrpShipType.php @@ -6,5 +6,12 @@ use Illuminate\Database\Eloquent\Model; class SrpShipType extends Model { - // + //Table Name + protected $table = 'srp_ship_types'; + + //Primary Key + public $primaryKey = 'id'; + + //Timestamps + public $timestamps = false; } diff --git a/database/migrations/2019_06_29_024757_create_srp_tables.php b/database/migrations/2019_06_29_024757_create_srp_tables.php index 1744860d2..985f8e6b4 100644 --- a/database/migrations/2019_06_29_024757_create_srp_tables.php +++ b/database/migrations/2019_06_29_024757_create_srp_tables.php @@ -31,6 +31,97 @@ class CreateSrpTables extends Migration $table->timestamps(); }); } + + if(!Schema::hasTable('srp_fleet_types')) { + Schema::create('srp_fleet_types', function (Blueprint $table) { + $table->increments('id'); + $table->string('code'); + $table->string('description'); + }); + } + + if(!Schema::hasTable('srp_ship_types')) { + Schema::create('srp_ship_types', function (Blueprint $table) { + $table->increments('id'); + $table->string('code'); + $table->string('description'); + }); + } + + DB::table('srp_fleet_types')->insert([ + 'code' => 'None', + 'description' => 'None', + ]); + + DB::table('srp_fleet_types')->insert([ + 'code' => 'Home Defense', + 'description' => 'Home Defense', + ]); + + DB::table('srp_fleet_types')->insert([ + 'code' => 'Legacy Ops', + 'description' => 'Legacy Ops', + ]); + + DB::table('srp_fleet_types')->insert([ + 'code' => 'Strat Op', + 'description' => 'Strat Op', + ]); + + DB::table('srp_fleet_types')->insert([ + 'code' => 'CTA', + 'description' => 'CTA', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'None', + 'description' => 'None', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'T1FDC', + 'description' => 'T1 Frig / Dessie / Cruiser', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'T1BC', + 'description' => 'T1 Battelcruiser', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'T2F', + 'description' => 'T2 Frigate', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'T3D', + 'description' => 'T3 Destroyer', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'T1T2Logi', + 'description' => 'T1 & T2 Logistics', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'RI', + 'description' => 'Recons / Interdictors', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'T2C', + 'description' => 'T2 Cruiser', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'T3C', + 'description' => 'T3 Cruiser', + ]); + + DB::table('srp_ship_types')->insert([ + 'code' => 'COM', + 'description' => 'Command Ship', + ]); } /**