Files
im-demo-server/app/Services/Base/BaseService.php

30 lines
558 B
PHP
Raw Normal View History

2025-06-25 16:12:51 +08:00
<?php
namespace App\Services\Base;
2025-06-26 09:56:14 +08:00
use App\Models\UserModel;
2025-06-25 16:12:51 +08:00
class BaseService
{
protected $userId;
2025-06-26 09:56:14 +08:00
protected $userInfo;
2025-06-25 16:12:51 +08:00
protected static $instance;
public function __construct()
{
$token = request()->header('token');
$this->userId = $token;
2025-06-26 09:56:14 +08:00
$this->userInfo = UserModel::where('id', $token)->first();
2025-06-25 16:12:51 +08:00
}
// 单例
public static function getInstance()
{
if (!self::$instance instanceof self) {
self::$instance = new self();
}
return self::$instance;
}
}