改进 模块罗列
This commit is contained in:
parent
b832c47016
commit
365c36bef2
@ -12,7 +12,7 @@ class HomeController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
$modules = (new Module)->paginate(10);
|
||||
$modules = (new Module)->whereHasBalance("0.01")->paginate(10);
|
||||
|
||||
return view('admin.index', compact('modules'));
|
||||
}
|
||||
|
@ -3,8 +3,10 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Exceptions\User\BalanceNotEnoughException;
|
||||
use GeneaLabs\LaravelModelCaching\CachedBuilder;
|
||||
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Http\Client\Response;
|
||||
@ -271,4 +273,14 @@ public function charge(string|null $amount = '0', string $payment = 'console', s
|
||||
|
||||
return $this->balance;
|
||||
}
|
||||
|
||||
public function hasBalance(string $amount = '0'): bool
|
||||
{
|
||||
return bccomp($this->balance, $amount, 4) >= 0;
|
||||
}
|
||||
|
||||
public function whereHasBalance(string $amount = "0"): self|Builder|CachedBuilder
|
||||
{
|
||||
return $this->where('balance', '>=', $amount);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user