BNav.php
2.1 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
namespace App\Models\Nav;
use App\Models\Base;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* b端控制, c端显示的导航
* @author:dc
* @time 2023/5/8 16:14
* Class BNav
* @package App\Models
*/
class BNav extends Base
{
protected $table = 'gl_web_nav';
//连接数据库
protected $connection = 'custom_mysql';
use SoftDeletes;
public $hidden = ['deleted_at'];
public $appends = ['able_import'];
/**
* 显示
*/
const STATUS_ACTIVE = 1;
/**
* 隐藏
*/
const STATUS_DISABLED = 0;
/**
* @author zbj
* @date 2023/11/22
*/
public static function ableImportMap($url=''){
$map = [
'products' => '\\App\\Models\\Product\\Category',
'news' => '\\App\\Models\\News\\NewsCategory',
'blog' => '\\App\\Models\\Blog\\BlogCategory',
];
if ($url){
return $map[$url] ?:"";
}
return $map;
}
/**
* 是否有下级
* @param int $id
* @param int $project_id
* @return mixed
* @author:dc
* @time 2023/5/9 9:23
*/
public static function isChild(int $id,int $project_id=0)
{
return static::where(['pid'=>$id,'project_id'=>$project_id])->limit(1)->count();
}
/**
* @remark :获取图片
* @name :getImageAttribute
* @author :lyh
* @method :post
* @time :2023/9/18 16:20
*/
public function getImageAttribute($value)
{
$value = getImageUrl($value);
return $value;
}
/**
* @remark :获取图片
* @name :getImageAttribute
* @author :lyh
* @method :post
* @time :2023/9/18 16:20
*/
public function getRemarkImageAttribute($value)
{
$value = getImageUrl($value);
return $value;
}
/**
* 是否支持一键导入
* @param $value
* @return int
* @author zbj
* @date 2023/11/21
*/
public function getAbleImportAttribute($value)
{
if(in_array($this->url, array_keys(self::ableImportMap()))){
return 1;
}
return 0;
}
}