connection = 'redis'; $this->onQueue('miningtaxes'); //Import variables from the calling function $this->ledger = $ledger; $this->observerId = $observerId; } /** * Execute the job. * * @return void */ public function handle() { $lookup = new LookupHelper; $mHelper = new MoonCalc; $config = config('esi'); //Create a starting date for the ledger $ledgerDate = Carbon::createFromFormat('Y-m-d', $this->ledger->last_updated); //If the ledger is more than one day old, then process it, otherwise, we don't process it //or add it to the database as it may still be updating. if($ledgerDate->lessThan(Carbon::now()->subDay())) { //Get some of the basic information we need to work with $charName = $lookup->CharacterIdToName($this->ledger->character_id); //Get the type name from the ledger ore $typeName = $lookup->ItemIdToName($this->ledger->type_id); //Get the price from the helper function $price = $mHelper->CalculateOrePrice($this->ledger->type_id); //Calculate the total price based on the amount $amount = (($price * $this->ledger->quantity) * $config['refine_rate']); $found = Ledger::where([ 'character_id' => $this->ledger->character_id, 'observer_id' => $this->observerId, 'type_id' => $this->ledger->type_id, 'last_updated' => $this->ledger->last_updated, ])->count(); if($found == 0) { $ledg = new Ledger; $ledg->character_id = $this->ledger->character_id; $ledg->character_name = $charName; $ledg->observer_id = $this->observerId; $ledg->last_updated = $this->ledger->last_updated; $ledg->type_id = $this->ledger->type_id; $ledg->ore_name = $typeName; $ledg->quantity = $this->ledger->quantity; $ledg->amount = $amount; $ledg->save(); } } return 0; } /** * Set the tags for Horzion * * @var array */ public function tags() { return ['ProcessMiningTaxesLedgers', 'MiningTaxes', 'MiningTaxesLedgers']; } }