refactor: 修改文件详情接口添加分类名称字段输出
This commit is contained in:
@@ -63,13 +63,18 @@ class Article
|
|||||||
// 文章详情
|
// 文章详情
|
||||||
public function read()
|
public function read()
|
||||||
{
|
{
|
||||||
$article = ArticleModel::withoutField([
|
$article = ArticleModel::with(['category' => function($query) {
|
||||||
|
$query->field(['id', 'name' => 'category_name']);
|
||||||
|
}])
|
||||||
|
->withoutField([
|
||||||
'language_id',
|
'language_id',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
'deleted_at',
|
'deleted_at',
|
||||||
])
|
])
|
||||||
->bypk(request()->param('id'))
|
->bypk(request()->param('id'))
|
||||||
->find();
|
->find()
|
||||||
|
->bindAttr('category', ['category_name'])
|
||||||
|
->hidden(['category']);
|
||||||
if (is_null($article)) {
|
if (is_null($article)) {
|
||||||
return error('文章不存在');
|
return error('文章不存在');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user