fleet stuff
This commit is contained in:
@@ -23,7 +23,6 @@ class FleetsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function displayFleets() {
|
public function displayFleets() {
|
||||||
//$fleets = DB::table('Fleets')->get();
|
|
||||||
$fleets = \App\Models\Fleet::all();
|
$fleets = \App\Models\Fleet::all();
|
||||||
$data = array();
|
$data = array();
|
||||||
$fc = array();
|
$fc = array();
|
||||||
@@ -51,7 +50,14 @@ class FleetsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function registerFleet(Request $request) {
|
public function registerFleet(Request $request) {
|
||||||
|
//Register a new instance of the fleet class
|
||||||
$fleet = new Fleet(Auth::user()->character_id);
|
$fleet = new Fleet(Auth::user()->character_id);
|
||||||
|
//Check to see if the character registering the fleet has the correct scope
|
||||||
|
if(!$fleet->HaveEsiScope($fc, 'esi-fleets.write_fleet.v1')) {
|
||||||
|
return view('inc.error')->with('error', 'User does not have the write fleet scope.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Make the fleet uri so we can call later functions
|
||||||
$fleetUri = $fleet->SetFleetUri($request->fleetUri);
|
$fleetUri = $fleet->SetFleetUri($request->fleetUri);
|
||||||
|
|
||||||
//Check for the fleet in the database
|
//Check for the fleet in the database
|
||||||
@@ -102,7 +108,13 @@ class FleetsController extends Controller
|
|||||||
//Add a pilot to the fleet
|
//Add a pilot to the fleet
|
||||||
$error = $newPilot->AddPilot($fleet[0]->character_id, $charId, $fleetId);
|
$error = $newPilot->AddPilot($fleet[0]->character_id, $charId, $fleetId);
|
||||||
|
|
||||||
return view('/dashboard');
|
if($error === null) {
|
||||||
|
return view('/dashboard')->with('success', 'Invite for fleet sent.');
|
||||||
|
} else {
|
||||||
|
return view('inc.error')->with('error', $error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateFleet() {
|
public function updateFleet() {
|
||||||
|
|||||||
@@ -124,6 +124,30 @@ class MoonsController extends Controller
|
|||||||
'structure' => 'required',
|
'structure' => 'required',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if($request->input('firstquan') < 1.00) {
|
||||||
|
$firstQuan = $request->input('firstquan') * 100.00;
|
||||||
|
} else {
|
||||||
|
$firstQuan = $request->input('firstquan');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->input('secondquan') < 1.00) {
|
||||||
|
$firstQuan = $request->input('secondquan') * 100.00;
|
||||||
|
} else {
|
||||||
|
$firstQuan = $request->input('secondquan');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->input('thirdquan') < 1.00) {
|
||||||
|
$firstQuan = $request->input('thirdquan') * 100.00;
|
||||||
|
} else {
|
||||||
|
$firstQuan = $request->input('thirdquan');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->input('fourthquan') < 1.00) {
|
||||||
|
$firstQuan = $request->input('fourthquan') * 100.00;
|
||||||
|
} else {
|
||||||
|
$firstQuan = $request->input('fourthquan');
|
||||||
|
}
|
||||||
|
|
||||||
// Add new moon
|
// Add new moon
|
||||||
$moon = new Moon;
|
$moon = new Moon;
|
||||||
$moon->Region = $request->input('region');
|
$moon->Region = $request->input('region');
|
||||||
|
|||||||
@@ -85,11 +85,7 @@ class Fleet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function AddPilot($fc, $charId, $fleetId) {
|
public function AddPilot($fc, $charId, $fleetId) {
|
||||||
//Check if the fc has the right scope
|
|
||||||
if(!$this->HaveEsiScope($fc, 'esi-fleets.write_fleet.v1')) {
|
|
||||||
return 'Incorrect Scopes.';
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get the ESI token for the FC to add the new pilot
|
//Get the ESI token for the FC to add the new pilot
|
||||||
$token = DB::table('EsiTokens')->where('character_id', $fc)->get();
|
$token = DB::table('EsiTokens')->where('character_id', $fc)->get();
|
||||||
// Disable all caching by setting the NullCache as the
|
// Disable all caching by setting the NullCache as the
|
||||||
@@ -128,16 +124,17 @@ class Fleet {
|
|||||||
// ESI as a normal array.
|
// ESI as a normal array.
|
||||||
print_r($e->getEsiResponse());
|
print_r($e->getEsiResponse());
|
||||||
dd($e->getEsiResponse());
|
dd($e->getEsiResponse());
|
||||||
|
return $e->getEsiResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Invite Sent';
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function RenderFleetDisplay() {
|
public function RenderFleetDisplay() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
private function HaveEsiScope($charId, $scope) {
|
public function HaveEsiScope($charId, $scope) {
|
||||||
//Check for an esi scope
|
//Check for an esi scope
|
||||||
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
|
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
|
||||||
foreach($checks as $check) {
|
foreach($checks as $check) {
|
||||||
|
|||||||
16
resources/views/inc/error.blade.php
Normal file
16
resources/views/inc/error.blade.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
@extends('layout.b4')
|
||||||
|
@section('content')
|
||||||
|
<div class="container">
|
||||||
|
<div class="card-header">
|
||||||
|
Error
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
@foreach($errors as $error)
|
||||||
|
<div class="alert alert-error" role="alert">
|
||||||
|
You have encountered an error.<br>
|
||||||
|
<?php printf($error); ?><br>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
Reference in New Issue
Block a user