This commit is contained in:
2021-05-24 22:12:37 +09:00
parent fbcd7dd957
commit 0107f24de8
3 changed files with 22 additions and 49 deletions
+16 -47
View File
@@ -36,6 +36,7 @@ class TestController extends Controller
public function DebugMiningTaxesInvoices() { public function DebugMiningTaxesInvoices() {
$lookup = new LookupHelper; $lookup = new LookupHelper;
$ledgers = new Collection; $ledgers = new Collection;
$perms = new Collection;
//Get all of the users in the database //Get all of the users in the database
@@ -44,59 +45,27 @@ class TestController extends Controller
//Get a list of the alts for each character, then process the ledgers and combine them to send one mail out //Get a list of the alts for each character, then process the ledgers and combine them to send one mail out
//in this first part //in this first part
foreach($users as $char) { foreach($users as $char) {
$alts = $char->userAlts(); $altCount = $char->altCount();
if($altCount > 0) {
$alts = $char->userAlts();
$mainLedgers = Ledger::where([ foreach($alts as $alt) {
'character_id' => $char->character_id, $perms->push([
'invoiced' => 'Yes', 'main_id' => $char->character_id,
])->get(); 'alt_id' => $alt->character_id,
'count' => $altCount,
if(Ledger::where([
'character_id' => $char->character_id,
])->count() > 0) {
foreach($mainLedgers as $row) {
$ledgers->push([
'main_id' => $row->character_id,
'character_id' => $row->character_id,
'character_name' => $row->character_name,
'observer_id' => $row->observer_id,
'last_updated' => $row->last_updated,
'type_id' => $row->type_id,
'ore_name' => $row->ore_name,
'quantity' => $row->quantity,
'amount' => $row->amount,
'invoiced' => $row->invoiced,
'invoice_id' => $row->invoice_id,
]); ]);
} }
} } else {
$perms->push([
foreach($alts as $alt) { 'main_id' => $char->character_id,
if($alt->character_id != $char->character_id) { 'alt_id' => null,
$ledgerRows = Ledger::where([ 'count' => 0,
'character_id' => $alt->character_id, ])
'invoiced' => 'Yes',
])->get();
if($ledgerRows->count() > 0) {
$ledgers->push([
'main_id' => $char->character_id,
'character_id' => $alt->character_id,
'observer_id' => $row->observer_id,
'last_updated' => $row->last_updated,
'type_id' => $row->type_id,
'ore_name' => $row->ore_name,
'quantity' => $row->quantity,
'amount' => $row->amount,
'invoiced' => $row->invoiced,
'invoice_id' => $row->invoice_id,
]);
}
}
} }
} }
return view('test.miningtax.invoice')->with('ledgers', $ledgers); return view('test.miningtax.invoice')->with('perms', $perms);
} }
public function DebugMiningObservers() { public function DebugMiningObservers() {
+4
View File
@@ -63,6 +63,10 @@ class User extends Authenticatable
return $this->hasMany('App\Models\User\UserAlt', 'character_id', 'main_id'); return $this->hasMany('App\Models\User\UserAlt', 'character_id', 'main_id');
} }
public function altCount() {
return $this->hasMany('App\Models\User\UserAlt', 'character_id', 'main_id')->count();
}
public function hasPermission($permission) { public function hasPermission($permission) {
$found = UserPermission::where(['character_id' => $this->character_id, 'permission' => $permission])->get(['permission']); $found = UserPermission::where(['character_id' => $this->character_id, 'permission' => $permission])->get(['permission']);
foreach($found as $foo) { foreach($found as $foo) {
@@ -1,4 +1,4 @@
@extends('layouts.user.dashb4'); @extends('layouts.user.dashb4');
@section('content') @section('content')
{{ var_dump($ledgers) }} {{ var_dump($perms) }}
@endsection @endsection