diff --git a/app/Jobs/Commands/MiningTaxes/FetchMiningTaxesLedgersJob.php b/app/Jobs/Commands/MiningTaxes/FetchMiningTaxesLedgersJob.php index c8b940a8a..cf68315f3 100644 --- a/app/Jobs/Commands/MiningTaxes/FetchMiningTaxesLedgersJob.php +++ b/app/Jobs/Commands/MiningTaxes/FetchMiningTaxesLedgersJob.php @@ -114,6 +114,7 @@ class FetchMiningTaxesLedgersJob implements ShouldQueue $item = Ledger::updateOrCreate([ 'character_id' => $ledger->character_id, 'character_name' => $charName, + 'observer_id' => $this->observerId, 'last_updated' => $updated, 'type_id' => $ledger->type_id, 'ore_name' => $typeName, @@ -122,6 +123,7 @@ class FetchMiningTaxesLedgersJob implements ShouldQueue ], [ 'character_id' => $ledger->character_id, 'character_name' => $charName, + 'observer_id' => $this->observerId, 'last_updated' => $updated, 'type_id' => $ledger->type_id, 'ore_name' => $typeName, diff --git a/app/Models/MiningTax/Invoice.php b/app/Models/MiningTax/Invoice.php index eb38443cf..6d679e314 100644 --- a/app/Models/MiningTax/Invoice.php +++ b/app/Models/MiningTax/Invoice.php @@ -26,4 +26,28 @@ class Invoice extends Model 'date_due', 'status', ]; + + public function getPayment() { + return $this->hasMany('App\Models\MiningTax\Payment', 'invoice_id', 'invoice_id'); + } + + public function getCharacterId() { + return $this->character_id; + } + + public function getCharacterName() { + return $this->character_name; + } + + public function getStatus() { + return $this->status; + } + + public function getLedgers() { + return $this->hasMany('App\Models\MiningTax\Ledger', 'invoice_id', 'invoice_id'); + } + + public function getInvoiceAmount() { + return $this->invoice_amount; + } } diff --git a/app/Models/MiningTax/Ledger.php b/app/Models/MiningTax/Ledger.php index 810dd4767..1e68aedf0 100644 --- a/app/Models/MiningTax/Ledger.php +++ b/app/Models/MiningTax/Ledger.php @@ -6,6 +6,9 @@ use Illuminate\Database\Eloquent\Model; class Ledger extends Model { + + use ReplaceableModel; + //Table Name protected $table = 'alliance_mining_tax_ledgers'; @@ -19,6 +22,8 @@ class Ledger extends Model */ protected $fillable = [ 'character_id', + 'character_name', + 'observer_id', 'last_updated', 'type_id', 'ore_name', @@ -27,4 +32,10 @@ class Ledger extends Model 'invoiced', 'invoice_id', ]; + + public function getInvoice() { + return $this->belongsTo('App\Models\MiningTax\Invoice', 'invoice_id', 'invoice_id'); + } + + } diff --git a/app/Models/MiningTax/Observer.php b/app/Models/MiningTax/Observer.php index d2067f389..016016e1e 100644 --- a/app/Models/MiningTax/Observer.php +++ b/app/Models/MiningTax/Observer.php @@ -22,4 +22,10 @@ class Observer extends Model 'observer_id', 'observer_type', ]; + + public function getLedgers() { + return $this->hasMany('App\Models\MiningTax\Ledger', 'observer_id', 'observer_id'); + } + + } diff --git a/app/Models/MiningTax/Payment.php b/app/Models/MiningTax/Payment.php index dc71d9308..ad9741f58 100644 --- a/app/Models/MiningTax/Payment.php +++ b/app/Models/MiningTax/Payment.php @@ -26,4 +26,8 @@ class Payment extends Model 'payment_date', 'status', ]; + + public function getInvoice() { + return $this->belongsTo('App\Models\MiningTax\Invoice', 'invoice_id', 'invoice_id'); + } } diff --git a/database/migrations/2021_01_10_164334_create_mining_tax_tables.php b/database/migrations/2021_01_10_164334_create_mining_tax_tables.php index 50c87013b..fb603b6f5 100644 --- a/database/migrations/2021_01_10_164334_create_mining_tax_tables.php +++ b/database/migrations/2021_01_10_164334_create_mining_tax_tables.php @@ -18,8 +18,8 @@ class CreateMiningTaxTables extends Migration $table->id(); $table->unsignedBigInteger('character_id'); $table->string('character_name'); - $table->unsignedBigInteger('invoice_id'); - $table->float('invoice_amount'); + $table->unsignedBigInteger('invoice_id')->nullable(); + $table->float('invoice_amount')->default(0.00); $table->dateTime('date_issued'); $table->dateTime('date_due'); $table->enum('status', [ @@ -49,9 +49,10 @@ class CreateMiningTaxTables extends Migration $table->id(); $table->unsignedBigInteger('character_id'); $table->string('character_name'); + $table->unsignedBigInteger('observer_id')->nullable(); $table->dateTime('last_updated'); - $table->unsignedBigInteger('type_id'); - $table->string('ore_name'); + $table->unsignedBigInteger('type_id')->default(0); + $table->string('ore_name')->default('None'); $table->unsignedBigInteger('quantity'); $table->decimal('amount', 20, 2)->default(0.00); $table->enum('invoiced', [