refactor: comment out update-check routes and refactor findUserByBearerToken, calcResetDayByMonthFirstDay, calcResetDayByExpireDay

This commit is contained in:
xboard
2025-05-24 20:47:27 +08:00
parent 7c86193215
commit fadeacf6f8
3 changed files with 16 additions and 16 deletions

View File

@@ -16,9 +16,7 @@ use App\Http\Controllers\V2\Admin\KnowledgeController;
use App\Http\Controllers\V2\Admin\PaymentController;
use App\Http\Controllers\V2\Admin\SystemController;
use App\Http\Controllers\V2\Admin\ThemeController;
use App\Http\Controllers\V2\Admin\UpdateController;
use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Support\Facades\Route;
class AdminRoute
{
@@ -197,12 +195,12 @@ class AdminRoute
});
// Update
$router->group([
'prefix' => 'update'
], function ($router) {
$router->get('/check', [UpdateController::class, 'checkUpdate']);
$router->post('/execute', [UpdateController::class, 'executeUpdate']);
});
// $router->group([
// 'prefix' => 'update'
// ], function ($router) {
// $router->get('/check', [UpdateController::class, 'checkUpdate']);
// $router->post('/execute', [UpdateController::class, 'executeUpdate']);
// });
// Theme
$router->group([

View File

@@ -58,7 +58,9 @@ class AuthService
$accessToken = PersonalAccessToken::findToken($token);
return $accessToken?->tokenable;
$tokenable = $accessToken?->tokenable;
return $tokenable instanceof User ? $tokenable : null;
}
/**

View File

@@ -14,20 +14,20 @@ class UserService
{
private function calcResetDayByMonthFirstDay(): int
{
$today = date('d');
$lastDay = date('d', strtotime('last day of +0 months'));
$today = (int) date('d');
$lastDay = (int) date('d', strtotime('last day of +0 months'));
return $lastDay - $today;
}
private function calcResetDayByExpireDay(int $expiredAt)
{
$day = date('d', $expiredAt);
$today = date('d');
$lastDay = date('d', strtotime('last day of +0 months'));
if ((int) $day >= (int) $today && (int) $day >= (int) $lastDay) {
$day = (int) date('d', $expiredAt);
$today = (int) date('d');
$lastDay = (int) date('d', strtotime('last day of +0 months'));
if ($day >= $today && $day >= $lastDay) {
return $lastDay - $today;
}
if ((int) $day >= (int) $today) {
if ($day >= $today) {
return $day - $today;
}