作者 邓超

xd

@@ -32,78 +32,7 @@ class BCustom extends Base @@ -32,78 +32,7 @@ class BCustom extends Base
32 const STATUS_DISABLED = 0; 32 const STATUS_DISABLED = 0;
33 33
34 34
35 - /**  
36 - * 创建或者新增导航栏  
37 - * @param int $project_id  
38 - * @param array $data  
39 - * @param int $id  
40 - * @return int  
41 - * @author:dc  
42 - * @time 2023/5/8 16:24  
43 - */  
44 - public static function _save(int $project_id, array $data, int $id = 0):int {  
45 - if($id){  
46 - $model = static::where('id',$id)->where('project_id', $project_id)->first();  
47 - if(!$model){  
48 - return -1;  
49 - }  
50 - }else{  
51 - $model = new static();  
52 - $model->project_id = $project_id;  
53 -  
54 - }  
55 -  
56 - $model->name = $data['name'];  
57 - $model->title = $data['title'];  
58 - $model->keywords = $data['keywords'];  
59 - $model->description = $data['description'];  
60 - $model->url = $data['url'];  
61 - $model->status = $data['status'];  
62 - $model->html = $data['html']??'';  
63 -  
64 - $model->save();  
65 -  
66 - // 创建路由标识  
67 - try {  
68 - RouteMap::setRoute($model->url,RouteMap::SOURCE_CUSTOM,$model->id,$project_id);  
69 - }catch (\Throwable $e){  
70 -  
71 - }  
72 -  
73 -  
74 - return $model->id;  
75 - }  
76 -  
77 35
78 - /**  
79 - * 删除  
80 - * @param int $project_id  
81 - * @param int $id  
82 - * @return mixed  
83 - * @author:dc  
84 - * @time 2023/5/8 16:27  
85 - */  
86 - public static function _del(int $project_id, int $id){  
87 - return static::where(['project_id'=>$project_id,'id'=>$id])->delete();  
88 - }  
89 -  
90 -  
91 - /**  
92 - * 查询当前项目下的所有信息  
93 - * @param int $project_id  
94 - * @return mixed  
95 - * @author:dc  
96 - * @time 2023/5/8 16:29  
97 - */  
98 - public static function _all(int $project_id, int $limit = 20)  
99 - {  
100 - return static::where(function ($query) use ($project_id){  
101 - // 那个公司  
102 - $query->where('project_id',$project_id);  
103 - })  
104 - ->select(['id','name','title','status','url','keywords','description','created_at','updated_at'])  
105 - ->paginate($limit);  
106 - }  
107 36
108 /** 37 /**
109 * 查询一条数据 38 * 查询一条数据