|
@@ -116,7 +116,10 @@ class NewsController extends Controller
|
116
|
116
|
$locate = $locale == "tw" ? "zh_TW" : $locale;
|
117
|
117
|
$news = News::find($id);
|
118
|
118
|
$otherNewsList = [];
|
119
|
|
-
|
|
119
|
+ if(!$news){
|
|
120
|
+ return response()->json([
|
|
121
|
+ 'message' => "news not found"], 404);
|
|
122
|
+ }
|
120
|
123
|
//取得前一篇
|
121
|
124
|
$previous = News::where(function ($query) use ($news) {
|
122
|
125
|
$query->where('order', $news->order)
|
|
@@ -167,7 +170,7 @@ class NewsController extends Controller
|
167
|
170
|
"id" => $next->id,
|
168
|
171
|
"categoryId" => $next->newsCategory->id,
|
169
|
172
|
"category" => $next->newsCategory->getTranslation("name", $locate, false),
|
170
|
|
- "postDate" => Carbon::parse($previous->post_date)->format("Y/m/d"),
|
|
173
|
+ "postDate" => Carbon::parse($next->post_date)->format("Y/m/d"),
|
171
|
174
|
"title" => $next->getTranslation("title", $locate, false),
|
172
|
175
|
"imgPC" => $next->news_img_pc_url,
|
173
|
176
|
"imgMobile" => $next->news_img_mobile_url,
|
|
@@ -175,22 +178,6 @@ class NewsController extends Controller
|
175
|
178
|
"description" => $next->getTranslation("description", $locate, false),
|
176
|
179
|
];
|
177
|
180
|
|
178
|
|
-
|
179
|
|
- // {
|
180
|
|
- // "type": "text",
|
181
|
|
- // "content": ""
|
182
|
|
- // },
|
183
|
|
- // {
|
184
|
|
- // "type": "image",
|
185
|
|
- // "images":[{"img_url":"", "alt":""}, {"img_url":"", "alt":""}]
|
186
|
|
- // },
|
187
|
|
- // {
|
188
|
|
- // "type": "video",
|
189
|
|
- // "is_yt":false,
|
190
|
|
- // "video_img_url":"",
|
191
|
|
- // "video_url":"",
|
192
|
|
- // "content": ""
|
193
|
|
- // }
|
194
|
181
|
$paragraphs = [];
|
195
|
182
|
foreach($news->paragraphs as $paragraph){
|
196
|
183
|
$content = [];
|
|
@@ -236,9 +223,9 @@ class NewsController extends Controller
|
236
|
223
|
"metaKeyword" => $news->getTranslation("meta_keyword", $locate, false),
|
237
|
224
|
"metaDesc" => $news->getTranslation("meta_description", $locate, false),
|
238
|
225
|
"metaImg" => $news->meta_img,
|
239
|
|
- "paragraphs" => $paragraphs,
|
240
|
|
- "otherNews" => $otherNewsList
|
|
226
|
+ "paragraphs" => $paragraphs
|
241
|
227
|
];
|
|
228
|
+ if(!empty($otherNewsList)) $result["otherNews"] = $otherNewsList;
|
242
|
229
|
return response()->json(["data" => $result], 200);
|
243
|
230
|
}
|
244
|
231
|
}
|