diff --git a/app/Console/Commands/MoonRental/ExecuteUpdateAllianceMoonRentalWorth.php b/app/Console/Commands/MoonRental/ExecuteUpdateAllianceMoonRentalWorth.php index e55a013ff..e024fcb01 100644 --- a/app/Console/Commands/MoonRental/ExecuteUpdateAllianceMoonRentalWorth.php +++ b/app/Console/Commands/MoonRental/ExecuteUpdateAllianceMoonRentalWorth.php @@ -2,8 +2,20 @@ namespace App\Console\Commands\MoonRental; +//Application Library use Illuminate\Console\Command; +use Log; +use Carbon\Carbon; +//Internal Library +use App\Library\Moons\MoonCalc; +use App\Library\Helpers\LookupHelper; + +//Models +use App\Models\MoonRental\AllianceMoon; +use App\Models\MoonRental\AllianceMoonOre; + +//Jobs use App\Jobs\Commands\MoonRental\UpdateAllianceMoonRentalWorth; class ExecuteUpdateAllianceMoonRentalWorth extends Command @@ -39,7 +51,37 @@ class ExecuteUpdateAllianceMoonRentalWorth extends Command */ public function handle() { - UpdateAllianceMoonRentalWorth::dispatch(); + //UpdateAllianceMoonRentalWorth::dispatch(); + + //Declare variables + $lookup = new LookupHelper; + $mHelper = new MoonCalc; + $months = 3; + $rentalTax = 0.25; + + $moons = AllianceMoon::all(); + + foreach($moons as $moon) { + //Declare the arrays needed + $ores = array(); + + $ores = AllianceMoonOre::where([ + 'moon_id' => $moon->moon_id, + ])->get(['ore_name', 'quantity'])->toArray(); + + //one of these two ways will work + $worth = $mHelper->MoonTotalWorth($ores[0][0], $ores[0][1], $ores[1][0], $ores[1][1], $ores[2][0], $ores[2][1], $ores[3][0], $ores[3][1]); + dd($worth); + $worth = $mHelper->MoonTotalWorth($ores[0], $ores[1], $ores[2], $ores[3], $ores[4], $ores[5], $ores[6], $ores[7]); + $rentalAmount = $worth * $rentalTax * $months; + + AllianceMoon::where([ + 'moon_id' => $moon->moon_id, + ])->update([ + 'worth_amount' => $worth, + 'rental_amount' => $rentalAmount, + ]); + } return 0; }