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