SetStartStatus(); //Get the characters for each non-invoiced ledger entry $charIds = Ledger::where([ 'invoiced' => 'No', ])->distinct('character_id') ->pluck('character_id'); //If character ids are null, then there are no ledgers to process. if($charIds->count() == 0) { //Set the task status as done and Log the issue $task->SetStopStatus(); Log::warning("No characters found to send invoices to in MiningTaxesInvoices Command."); return 0; } /** * From the list of character ids, create an array of mains and alts to group together. */ foreach($charIds as $charId) { $invoice = array(); $ores = array(); $totalPrice = 0.00; $body = null; $mainId = null; //Determine if this character is an alt of someone else $foundAlt = UserAlt::where([ 'character_id' => $charId, ])->get(); if($foundAlt > 0) { $mainId = $foundAlt->main_id; } else { $mainId = $charId; } } //Set the task as stopped $task->SetStopStatus(); return 0; } }