From e6ca3ccded86ccd4b321f26a841f9d9dc4ba4608 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Sat, 19 Nov 2022 21:07:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Host.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/Models/Host.php b/app/Models/Host.php index a4f8f96..20cbf19 100644 --- a/app/Models/Host.php +++ b/app/Models/Host.php @@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias; use Illuminate\Database\Eloquent\Relations\HasMany as HasManyAlias; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Log; // use Illuminate\Database\Eloquent\SoftDeletes; @@ -121,7 +122,7 @@ public function workOrders(): HasManyAlias public function scopeActive($query) { - return $query->whereIn('status', ['running', 'stopped'])->where('price', '!=', 0)->where('managed_price', '!=', 0)->whereNotNull('managed_price'); + return $query->whereIn('status', ['running', 'stopped'])->where('price', '!=', 0)->orWhereNotNull('managed_price'); } public function scopeThisUser($query, $module = null) @@ -141,20 +142,21 @@ public function safeDelete(): bool public function cost($price = null, $auto = true): bool { + + Log::debug('Host::cost()'); $this->load('user'); $transaction = new Transaction(); $drops = $transaction->getDrops($this->user_id); - if ($price !== null) { - $real_price = $price; - } else { - if ($this->managed_price !== null) { - $real_price = $this->managed_price; - } + $real_price = $price ?? $this->price; + + if (!$price) { + $real_price = $this->managed_price; } + if ($real_price == 0) { return true; }