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