Compare commits
4 Commits
91b401870c
...
53da5b8a99
| Author | SHA1 | Date | |
|---|---|---|---|
| 53da5b8a99 | |||
| 7b82db2366 | |||
| 336b332572 | |||
| efdff61306 |
@@ -63,13 +63,18 @@ class Article
|
||||
// 文章详情
|
||||
public function read()
|
||||
{
|
||||
$article = ArticleModel::withoutField([
|
||||
$article = ArticleModel::with(['category' => function($query) {
|
||||
$query->field(['id', 'name' => 'category_name']);
|
||||
}])
|
||||
->withoutField([
|
||||
'language_id',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
])
|
||||
->bypk(request()->param('id'))
|
||||
->find();
|
||||
->find()
|
||||
->bindAttr('category', ['category_name'])
|
||||
->hidden(['category']);
|
||||
if (is_null($article)) {
|
||||
return error('文章不存在');
|
||||
}
|
||||
|
||||
@@ -61,14 +61,29 @@ class Attachment
|
||||
{
|
||||
$id = request()->param('id');
|
||||
|
||||
$attachment = AttachmentModel::withoutField([
|
||||
'language_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at'
|
||||
$attachment = AttachmentModel::with(['category' => function ($query) {
|
||||
$query->field(['id', 'name' => 'category_name']);
|
||||
}])
|
||||
->field([
|
||||
'id',
|
||||
'category_id',
|
||||
'name',
|
||||
'desc',
|
||||
'image',
|
||||
'applicable_to',
|
||||
'support_platform',
|
||||
'attach',
|
||||
'sort',
|
||||
'recommend',
|
||||
'status',
|
||||
'seo_title',
|
||||
'seo_keywords',
|
||||
'seo_desc'
|
||||
])
|
||||
->bypk($id)
|
||||
->find();
|
||||
->find()
|
||||
->bindAttr('category', ['category_name'])
|
||||
->hidden(['category']);
|
||||
if (empty($attachment)) {
|
||||
return error('附件不存在');
|
||||
}
|
||||
|
||||
@@ -71,14 +71,19 @@ class Product
|
||||
// 产品详情
|
||||
public function read()
|
||||
{
|
||||
$product = ProductModel::withoutField([
|
||||
$product = ProductModel::with(['category' => function($query) {
|
||||
$query->field(['id', 'name' => 'category_name']);
|
||||
}])
|
||||
->withoutField([
|
||||
'language_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at'
|
||||
])
|
||||
->bypk(request()->param('id'))
|
||||
->find();
|
||||
->find()
|
||||
->bindAttr('category', ['category_name'])
|
||||
->hidden(['category']);
|
||||
if (empty($product)) {
|
||||
return error('产品不存在');
|
||||
}
|
||||
|
||||
@@ -61,13 +61,18 @@ class Video
|
||||
*/
|
||||
public function read()
|
||||
{
|
||||
$video = VideoModel::withoutField([
|
||||
$video = VideoModel::with(['category' => function($query) {
|
||||
$query->field(['id', 'name' => 'category_name']);
|
||||
}])
|
||||
->withoutField([
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at'
|
||||
])
|
||||
->bypk(request()->param('id'))
|
||||
->find();
|
||||
->find()
|
||||
->bindAttr('category', ['category_name'])
|
||||
->hidden(['category']);
|
||||
if (empty($video)) {
|
||||
return error('视频不存在');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user