优化 代码
This commit is contained in:
parent
6213a50b4c
commit
11e1e16a6b
@ -7,20 +7,13 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class AuthController extends Controller
|
||||
{
|
||||
//
|
||||
|
||||
/**
|
||||
* @return View|RedirectResponse
|
||||
*/
|
||||
public function index(): View|RedirectResponse
|
||||
{
|
||||
// if not authed
|
||||
|
||||
if (!auth('admin')->check()) {
|
||||
return view('admin.login');
|
||||
} else {
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
//
|
||||
|
||||
public function index()
|
||||
{
|
||||
$modules = Module::paginate(10);
|
||||
|
@ -72,7 +72,6 @@ public function update(Request $request, Host $host): RedirectResponse
|
||||
*/
|
||||
public function destroy(Host $host): RedirectResponse
|
||||
{
|
||||
//
|
||||
$host->safeDelete();
|
||||
|
||||
return redirect()->route('admin.hosts.index')->with('success', '正在排队删除此主机。');
|
||||
|
@ -152,7 +152,6 @@ public function update(Request $request, Module $module): RedirectResponse
|
||||
public function destroy(Module $module): RedirectResponse
|
||||
{
|
||||
//
|
||||
|
||||
$module->delete();
|
||||
|
||||
return redirect()->route('admin.modules.index')->with('success', '模块已删除。');
|
||||
|
@ -80,8 +80,6 @@ public function update(Request $request, User $user)
|
||||
|
||||
$transaction = new Transaction();
|
||||
|
||||
// 检测是否为空
|
||||
|
||||
if ($request->filled('balance')) {
|
||||
$transaction->addAmount($user->id, 'console', $request->balance, '管理员汇入', true);
|
||||
}
|
||||
@ -110,7 +108,6 @@ public function update(Request $request, User $user)
|
||||
}
|
||||
$user->save();
|
||||
|
||||
// if dirty, save
|
||||
if ($user->isDirty()) {
|
||||
$user->save();
|
||||
}
|
||||
|
@ -4,17 +4,16 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Closure;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use function config;
|
||||
|
||||
// use Exception;
|
||||
// use Illuminate\Http\Request;
|
||||
|
||||
class ForumController extends Controller
|
||||
{
|
||||
|
||||
private $http, $baseUrl;
|
||||
private mixed $baseUrl;
|
||||
private PendingRequest $http;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -8,11 +8,8 @@
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany as HasManyAlias;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
// use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* App\Models\Host
|
||||
*
|
||||
@ -92,12 +89,8 @@ class Host extends Model
|
||||
protected $casts = [
|
||||
// 'configuration' => 'array',
|
||||
'suspended_at' => 'datetime',
|
||||
|
||||
];
|
||||
|
||||
|
||||
// user
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
@ -112,7 +105,6 @@ protected static function boot()
|
||||
if ($model->managed_price !== null) {
|
||||
$model->managed_price = round($model->managed_price, 2);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
static::created(function ($model) {
|
||||
@ -303,12 +295,8 @@ public function cost($amount = null, $auto = true): bool
|
||||
if ($auto) {
|
||||
// 获取本月天数
|
||||
$days = now()->daysInMonth;
|
||||
|
||||
// 本月每天的每小时的价格
|
||||
$real_price = $real_price / $days / 24;
|
||||
|
||||
// echo '计算' . $real_price . '元' . PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
if ($real_price == 0) {
|
||||
@ -383,7 +371,6 @@ public function addLog(float|null $amount = 0): bool
|
||||
$earnings[$current_year][$current_month]['balance'] += $amount;
|
||||
$earnings[$current_year][$current_month]['should_balance'] += $should_balance;
|
||||
} else {
|
||||
|
||||
$earnings[$current_year][$current_month] = [
|
||||
'balance' => $amount,
|
||||
// 应得(交了手续费)
|
||||
@ -394,7 +381,6 @@ public function addLog(float|null $amount = 0): bool
|
||||
// 删除 前 3 年的数据
|
||||
if (count($earnings) > 3) {
|
||||
$earnings = array_slice($earnings, -3, 3, true);
|
||||
|
||||
}
|
||||
|
||||
// 保存 1 年
|
||||
|
Loading…
Reference in New Issue
Block a user