作者 邓超

xd

... ... @@ -32,78 +32,7 @@ class BCustom extends Base
const STATUS_DISABLED = 0;
/**
* 创建或者新增导航栏
* @param int $project_id
* @param array $data
* @param int $id
* @return int
* @author:dc
* @time 2023/5/8 16:24
*/
public static function _save(int $project_id, array $data, int $id = 0):int {
if($id){
$model = static::where('id',$id)->where('project_id', $project_id)->first();
if(!$model){
return -1;
}
}else{
$model = new static();
$model->project_id = $project_id;
}
$model->name = $data['name'];
$model->title = $data['title'];
$model->keywords = $data['keywords'];
$model->description = $data['description'];
$model->url = $data['url'];
$model->status = $data['status'];
$model->html = $data['html']??'';
$model->save();
// 创建路由标识
try {
RouteMap::setRoute($model->url,RouteMap::SOURCE_CUSTOM,$model->id,$project_id);
}catch (\Throwable $e){
}
return $model->id;
}
/**
* 删除
* @param int $project_id
* @param int $id
* @return mixed
* @author:dc
* @time 2023/5/8 16:27
*/
public static function _del(int $project_id, int $id){
return static::where(['project_id'=>$project_id,'id'=>$id])->delete();
}
/**
* 查询当前项目下的所有信息
* @param int $project_id
* @return mixed
* @author:dc
* @time 2023/5/8 16:29
*/
public static function _all(int $project_id, int $limit = 20)
{
return static::where(function ($query) use ($project_id){
// 那个公司
$query->where('project_id',$project_id);
})
->select(['id','name','title','status','url','keywords','description','created_at','updated_at'])
->paginate($limit);
}
/**
* 查询一条数据
... ...