72 lines
1.8 KiB
PHP
72 lines
1.8 KiB
PHP
<?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();
|
|
}
|
|
}
|