04a2034975
- storefront 全站改为极简黑白配色:直角、细线分隔、卡片 hover 浅底、深色模式(跟随系统+手动切换) - 抽出 storefront/partials/card 复用卡片 - 一并提交此前暂存的客户端注册 API、站点设置、后台页面与测试 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class StoreClient extends Model
|
|
{
|
|
protected $table = 'store_clients';
|
|
|
|
protected $fillable = [
|
|
'site_url',
|
|
'site_name',
|
|
'access_token',
|
|
'status',
|
|
'user_count',
|
|
'typecho_version',
|
|
'php_version',
|
|
'plugin_version',
|
|
'last_ip',
|
|
'last_user_agent',
|
|
'registered_at',
|
|
'last_seen_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'user_count' => 'integer',
|
|
'registered_at' => 'datetime',
|
|
'last_seen_at' => 'datetime',
|
|
];
|
|
|
|
public function scopeOnline(Builder $query): Builder
|
|
{
|
|
return $query->whereNotNull('last_seen_at')
|
|
->where('last_seen_at', '>=', now()->subMinutes((int) config('store.client_online_window_minutes', 15)));
|
|
}
|
|
|
|
public function getIsOnlineAttribute(): bool
|
|
{
|
|
if (!$this->last_seen_at) {
|
|
return false;
|
|
}
|
|
|
|
return $this->last_seen_at->gte(
|
|
now()->subMinutes((int) config('store.client_online_window_minutes', 15))
|
|
);
|
|
}
|
|
|
|
public function getTokenSuffixAttribute(): string
|
|
{
|
|
$token = trim((string) $this->access_token);
|
|
if ($token === '') {
|
|
return '';
|
|
}
|
|
|
|
return substr($token, -8);
|
|
}
|
|
}
|