Files
hyperf_service/app/Service/ServiceTrait/Api/PhonePoolTrait.php
2025-04-10 13:41:39 +08:00

34 lines
752 B
PHP

<?php
namespace App\Service\ServiceTrait\Api;
use App\Lib\Log;
use App\Model\PhonePool;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
trait PhonePoolTrait
{
/**
* @var Log
*/
#[Inject]
protected Log $log;
/**
* @param string $mobile
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function addMobilePhone(string $mobile): void
{
if (empty($mobile)) return;
$insertModel = new PhonePool();
$insertModel->phone = $mobile;
if (!$insertModel->save()) $this->log->error('添加手机号到池子失败,mobile:'.$mobile);
}
}