WebSetting.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace App\Models\WebSetting;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Support\Facades\Redis;
class WebSetting extends Base
{
//锚文本常量配置在settingTextModel中
protected $table = 'gl_web_setting';
//连接数据库
protected $connection = 'custom_mysql';
//网站缓存过期时间
public static $redisExpireTime = 600;
public static $redisUpdateHtmlExpireTime = 60;
public static $okStatus = 200;
public static $errStatus = 500;
const SEO_TYPE_PUBLIC = 1;
const SEO_TYPE_OWN = 2;
/**
* 网站设置
*/
public static function getWebSetting($project)
{
if (Redis::get("project_".$project->id."_web_setting") == null) {
$webSetting = self::where("project_id", $project->id)->first();
if (!empty($webSetting)) {
Redis::set("project_".$project->id."_web_setting", json_encode($webSetting->toArray()));
} else {
Redis::set("project_".$project->id."_web_setting", null);
}
Redis::expire("project_".$project->id."_web_setting", WebSetting::$redisExpireTime);
}
return json_decode(Redis::get("project_".$project->id."_web_setting"));
}
/**
* @remark :是否开启锚文本
* @name :getIsCustomAnchorAttribute
* @author :lyh
* @method :post
* @time :2025/3/24 15:07
*/
public function getIsCustomAnchorAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
}
return $value;
}
}