Register Structure
This commit is contained in:
@@ -28,20 +28,20 @@ class RegisterStructureController extends Controller
|
||||
|
||||
public function storeStructure(Request $request) {
|
||||
$this->validate($request, [
|
||||
'corporation_id' => 'required',
|
||||
'corporation_name' => 'required',
|
||||
'system' => 'required',
|
||||
'structure_name' => 'required',
|
||||
'tax' => 'required',
|
||||
'structure_type' => 'required',
|
||||
]);
|
||||
|
||||
$eHelper = new Esi;
|
||||
|
||||
$tax = floatval($request->tax);
|
||||
|
||||
$structure = new CorpStructure();
|
||||
$structure->character_id = Auth::user()->character_id;
|
||||
$structure->corporation_id = $request->corporation_id;
|
||||
$structure->corporation_name = $request->corporation_name;
|
||||
$structure->corporation_id = $eHelper->FindCorporationId(Auth::user()->character_id);
|
||||
$structure->corporation_name = $eHelper->FindCorporationName(Auth::user()->character_id);
|
||||
$structure->region = $request->region;
|
||||
$structure->system = $request->system;
|
||||
$structure->structure_name = $request->structure_name;
|
||||
|
||||
@@ -16,7 +16,6 @@ use App\Models\Corporation\CorpStructure;
|
||||
|
||||
use App\Library\FinanceHelper;
|
||||
use App\Library\Esi;
|
||||
use App\Library\SeatHelper;
|
||||
|
||||
class StructureController extends Controller
|
||||
{
|
||||
@@ -43,7 +42,7 @@ class StructureController extends Controller
|
||||
$endLast->second = 59;
|
||||
|
||||
//Get the character's corporation from esi
|
||||
$corporation = $helper->FindCorporationName(Auth::user()->character_id);
|
||||
//$corporation = $helper->FindCorporationName(Auth::user()->character_id);
|
||||
$corpId = $helper->FindCorporationId(Auth::user()->character_id);
|
||||
|
||||
//Get the number of structures registered to a corporation
|
||||
@@ -72,30 +71,29 @@ class StructureController extends Controller
|
||||
/**
|
||||
* Calculate the final taxes and send to display
|
||||
*/
|
||||
$mTax = DB::select('SELECT AVG(tax) FROM CorpStructures WHERE 1');
|
||||
$mTax = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => 'Citadel'])->avg('tax');
|
||||
dd($mTax);
|
||||
$rTax = CorpStructure::where(['corporation_id' => $corpId, 'structure_type' => 'Refinery'])->avg('tax');
|
||||
|
||||
$monthTaxesMarket = $tempMonthTaxesMarket - $marketFuelCost;
|
||||
$monthTaxesMarket = $hFinances->CalculateTax($monthTaxesMarket, 2.5, 'market');
|
||||
$monthTaxesMarket = $hFinances->CalculateTax($monthTaxesMarket, $mTax, 'market');
|
||||
if($monthTaxesMarket < 0.00) {
|
||||
$monthTaxesMarket = 0.00;
|
||||
}
|
||||
|
||||
$lastTaxesMarket = $tempLastTaxesMarket - $marketFuelCost;
|
||||
$lastTaxesMarket = $hFinances->CalculateTax($lastTaxesMarket, 2.5, 'market');
|
||||
$lastTaxesMarket = $hFinances->CalculateTax($lastTaxesMarket, $mTax, 'market');
|
||||
if($lastTaxesMarket < 0.00) {
|
||||
$lastTaxesMarket = 0.00;
|
||||
}
|
||||
|
||||
$monthTaxesReprocessing = $tempMonthTaxesReprocessing - $refineryFuelCost;
|
||||
$monthTaxesReprocessing = $hFinances->CalculateTax($monthTaxesReprocessing, 2.5, 'refinery');
|
||||
$monthTaxesReprocessing = $hFinances->CalculateTax($monthTaxesReprocessing, $rTax, 'refinery');
|
||||
if($monthTaxesReprocessing < 0.00) {
|
||||
$monthTaxesReprocessing = 0.00;
|
||||
}
|
||||
|
||||
$lastTaxesReprocessing = $tempLastTaxesReprocessing - $refineryFuelCost;
|
||||
$lastTaxesReprocessing = $hFinances->CalculateTax($lastTaxesReprocessing, 2.5, 'refinery');
|
||||
$lastTaxesReprocessing = $hFinances->CalculateTax($lastTaxesReprocessing, $rTax, 'refinery');
|
||||
if($lastTaxesReprocessing < 0.00) {
|
||||
$lastTaxesReprocessing = 0.00;
|
||||
}
|
||||
|
||||
@@ -12,38 +12,7 @@ use GuzzleHttp\RequestOptions;
|
||||
|
||||
|
||||
class SeatHelper {
|
||||
|
||||
public function GetCorpJournal($corporationId, $page) {
|
||||
//Setup the guzzle client
|
||||
$guzzle = new Client([
|
||||
'headers' => [
|
||||
'X-Token' => 'EXXruHji5xYGO07C9W31cDjjZ0D3nPVw',
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
'X-CSRF-Token' => 'EXXruHji5xYGO07C9W31cDjjZ0D3nPVw',
|
||||
],
|
||||
]);
|
||||
$data = $guzzle->request('GET', 'https://seat.warpedintentions.com/api/v2/corporation/wallet-journal/' . $corporationId . '?page=' . $page);
|
||||
$body = $data->getBody()->getContents();
|
||||
$response = json_decode($body);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function DecodeDate($date) {
|
||||
//Find the end of the date
|
||||
$dateEnd = strpos($date, "T");
|
||||
//Split the string up into date and time
|
||||
$dateArr = str_split($date, $dateEnd);
|
||||
//Trim the T and Z from the end of the second item in the array
|
||||
$dateArr[1] = ltrim($dateArr[1], "T");
|
||||
$dateArr[1] = rtrim($dateArr[1], "Z");
|
||||
//Combine the date
|
||||
$realDate = $dateArr[0] . " " . $dateArr[1];
|
||||
|
||||
//Return the combined date in the correct format
|
||||
return $realDate;
|
||||
}
|
||||
// Nothing to do here right now
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -4,10 +4,6 @@
|
||||
<h2>Register Structure</h2>
|
||||
{!! Form::open(['action' => 'RegisterStructureController@storeStructure', 'method' => 'POST']) !!}
|
||||
<div class="form-group">
|
||||
{{ Form::label('corporation_id', 'Corporation ID')}}
|
||||
{{ Form::text('corporation_id', '', ['class' => 'form-control']) }}
|
||||
{{ Form::label('corporation_name', 'Corporation Name') }}
|
||||
{{ Form::text('corporation_name', '', ['class' => 'form-control']) }}
|
||||
{{ Form::label('region', 'Region') }}
|
||||
{{ Form::text('region', '', ['class' => 'form-control']) }}
|
||||
{{ Form::label('system', 'System') }}
|
||||
|
||||
Reference in New Issue
Block a user