改进 条件查询
This commit is contained in:
parent
bd1d3df700
commit
e6ca3ccded
@ -11,6 +11,7 @@
|
|||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany as HasManyAlias;
|
use Illuminate\Database\Eloquent\Relations\HasMany as HasManyAlias;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
// use Illuminate\Database\Eloquent\SoftDeletes;
|
// use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ public function workOrders(): HasManyAlias
|
|||||||
|
|
||||||
public function scopeActive($query)
|
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)
|
public function scopeThisUser($query, $module = null)
|
||||||
@ -141,19 +142,20 @@ public function safeDelete(): bool
|
|||||||
|
|
||||||
public function cost($price = null, $auto = true): bool
|
public function cost($price = null, $auto = true): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Log::debug('Host::cost()');
|
||||||
$this->load('user');
|
$this->load('user');
|
||||||
|
|
||||||
$transaction = new Transaction();
|
$transaction = new Transaction();
|
||||||
|
|
||||||
$drops = $transaction->getDrops($this->user_id);
|
$drops = $transaction->getDrops($this->user_id);
|
||||||
|
|
||||||
if ($price !== null) {
|
$real_price = $price ?? $this->price;
|
||||||
$real_price = $price;
|
|
||||||
} else {
|
if (!$price) {
|
||||||
if ($this->managed_price !== null) {
|
|
||||||
$real_price = $this->managed_price;
|
$real_price = $this->managed_price;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($real_price == 0) {
|
if ($real_price == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user