<?php
|
|
namespace app\common\model\plus\release;
|
|
use app\common\model\BaseModel;
|
|
/**
|
* 项目模型
|
*/
|
class Project extends BaseModel
|
{
|
protected $name = 'release_project';
|
protected $pk = 'project_id';
|
|
|
/**
|
* 关联上传图片表
|
*/
|
public function image()
|
{
|
return $this->hasMany('app\\common\\model\\plus\\release\\ReleaseProjectImage', 'project_id', 'id')->order(['id' => 'asc']);
|
}
|
|
/**
|
* 关联分类
|
* @return \think\model\relation\BelongsTo
|
*/
|
public function category()
|
{
|
return $this->belongsTo('app\\common\\model\\plus\\release\\ReleaseCategory','category_id','category_id');
|
}
|
|
/**
|
* 关联
|
* @return \think\model\relation\BelongsTo
|
*/
|
public function user()
|
{
|
return $this->belongsTo('app\\common\\model\\user\\User','user_id','user_id');
|
}
|
|
|
|
/**
|
* 关联多标签表
|
*/
|
public function tag()
|
{
|
return $this->hasMany('app\\common\\model\\plus\\release\\Tag', 'tag_id', 'tag_id');
|
}
|
/**
|
* 关联评论表
|
*/
|
public function evaluate()
|
{
|
return $this->hasMany('app\\common\\model\\plus\\release\\Evaluate', 'project_id', 'project_id')->order(['id' => 'desc']);
|
}
|
|
|
/**
|
* 获取详情
|
*/
|
public static function detail($project_id)
|
{
|
return (new static())->with(['image','evaluate','evaluate.user','category'])->find($project_id);
|
}
|
|
/**
|
* 获取列表记录
|
*/
|
public function getAll()
|
{
|
return $this->where('is_delete', '=', 0)
|
->field('project_id,name')
|
->order(['sort' => 'asc', 'create_time' => 'asc'])
|
->select();
|
}
|
}
|