6
0
Fork 0
jiqu-library-server/app/helpers.php

40 lines
829 B
PHP

<?php
use App\Services\SettingService;
if (! function_exists('app_settings')) {
/**
* 获取/设置应用设置项
*
* @param array|string $key
* @param mixed $default
* @return mixed
*
* @return mixed|\App\Services\SettingService
*/
function app_settings($key = null, $default = null)
{
if (is_null($key)) {
return app(SettingService::class);
}
if (is_array($key)) {
return app(SettingService::class)->set($key);
}
return app(SettingService::class)->get($key, $default);
}
}
if (! function_exists('serial_number')) {
/**
* 生成流水号
*
* @return string
*/
function serial_number(): string
{
return date('YmdHis').sprintf('%06d', mt_rand(1, 999999));
}
}