chore: 重写初始提交(清空历史,整理后全量提交)
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: ywxapp<admin@ywxapp.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace addon\docs\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 文档项目模型
|
||||
*
|
||||
* @author ywxapp <admin@ywxapp.cn>
|
||||
*/
|
||||
class DocsProject extends Model
|
||||
{
|
||||
protected $name = 'docs_project';
|
||||
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'create_at';
|
||||
protected $updateTime = 'update_at';
|
||||
|
||||
protected $type = [
|
||||
'id' => 'integer',
|
||||
'owner_uid' => 'integer',
|
||||
'sort' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 关联版本列表
|
||||
*/
|
||||
public function versions()
|
||||
{
|
||||
return $this->hasMany(DocsVersion::class, 'project_id', 'id')
|
||||
->order('sort', 'asc')
|
||||
->order('id', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 URL 标识获取启用中的项目
|
||||
*
|
||||
* @param string $name 项目标识
|
||||
* @return static|null
|
||||
*/
|
||||
public static function findByName(string $name)
|
||||
{
|
||||
if ($name === '') {
|
||||
return null;
|
||||
}
|
||||
return static::where('name', $name)->where('status', 1)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部启用项目(按排序)
|
||||
*
|
||||
* @return \think\Collection
|
||||
*/
|
||||
public static function enabledList()
|
||||
{
|
||||
return static::where('status', 1)
|
||||
->order('sort', 'asc')
|
||||
->order('id', 'asc')
|
||||
->select();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user