|
@@ -9,9 +9,11 @@ use App\Models\SearchRecord;
|
9
|
9
|
use App\Models\SearchStatistics;
|
10
|
10
|
use App\Models\Tag;
|
11
|
11
|
use App\Models\UserMessage;
|
|
12
|
+use App\Models\Special;
|
|
13
|
+use App\Models\News;
|
12
|
14
|
use Illuminate\Http\Request;
|
13
|
15
|
use Solr;
|
14
|
|
-
|
|
16
|
+use DB;
|
15
|
17
|
class FeaturesController extends BaseController
|
16
|
18
|
{
|
17
|
19
|
|
|
@@ -188,4 +190,101 @@ class FeaturesController extends BaseController
|
188
|
190
|
{
|
189
|
191
|
SearchRecord::insertSearchValue($value, $type);
|
190
|
192
|
}
|
|
193
|
+
|
|
194
|
+ //早中晚专题
|
|
195
|
+ public function earlyMiddleAndLateTheme(Request $request){
|
|
196
|
+ $data=Special::whereIn('title',['上午','中午','下午'])->get();
|
|
197
|
+ if (!$data) {
|
|
198
|
+ return $this->response->array(self::returnValue(['data' => 'Database error'], 9999));
|
|
199
|
+ }
|
|
200
|
+ return $this->response->array(self::returnValue(['data' => $data], 200));
|
|
201
|
+ }
|
|
202
|
+ //其他专题
|
|
203
|
+
|
|
204
|
+ /**
|
|
205
|
+ * @param Request $request
|
|
206
|
+ * @return mixed
|
|
207
|
+ */
|
|
208
|
+ public function otherTheme(Request $request){
|
|
209
|
+ $today=strtotime(date('Y-m-d'));
|
|
210
|
+ $data=Special::whereNotIn('title',['上午','中午','下午'])->where('status',1)->where('releaseTime','<',$today)->get();
|
|
211
|
+ $data=json_decode(json_encode($data),true);
|
|
212
|
+ $json_menu_idarr=Special::whereNotIn('title',['上午','中午','下午'])->where('status',1)->pluck('contain_recipes');
|
|
213
|
+ $json_menu_idarr=json_decode(json_encode($json_menu_idarr),true);
|
|
214
|
+ $initArr=array();
|
|
215
|
+ foreach($json_menu_idarr as $item){
|
|
216
|
+ if($item){
|
|
217
|
+ $initArr=array_merge($initArr,explode(',',$item));
|
|
218
|
+ }
|
|
219
|
+ }
|
|
220
|
+ $initArr=array_unique($initArr);
|
|
221
|
+ $menuAll=DB::table('menu')->whereIn('id',$initArr)->where('status',1)->get();
|
|
222
|
+ $menuAll=json_decode(json_encode($menuAll),true);
|
|
223
|
+ $middleArr=array();
|
|
224
|
+ foreach($menuAll as $item){
|
|
225
|
+ $middleArr["".$item['id']]=$item;
|
|
226
|
+ }
|
|
227
|
+ foreach($data as $key=>$item){
|
|
228
|
+ if($item['contain_recipes']){
|
|
229
|
+ foreach(explode(',',$item['contain_recipes']) as $inneritem){
|
|
230
|
+ $data[$key]['menuList'][]=$middleArr[$inneritem];
|
|
231
|
+ }
|
|
232
|
+ }
|
|
233
|
+ }
|
|
234
|
+ return $this->response->array(self::returnValue(['data' => $data], 200));
|
|
235
|
+ }
|
|
236
|
+ public function theLastRecipes(Request $request){
|
|
237
|
+ $data=Menu::where('status',1)->orderBy('created_at','desc')->limit(50)->get();
|
|
238
|
+ if (!$data) {
|
|
239
|
+ return $this->response->array(self::returnValue(['data' => 'Database error'], 9999));
|
|
240
|
+ }
|
|
241
|
+ return $this->response->array(self::returnValue(['data' => $data], 200));
|
|
242
|
+ }
|
|
243
|
+ public function menuList(Request $request){
|
|
244
|
+ $id=$request->input('id');
|
|
245
|
+ $special=Special::where('id',$id)->first();
|
|
246
|
+ if($special['title']=='上午' || $special['title']=='中午' || $special['title']=='下午'){
|
|
247
|
+ $contain_recipes_time=json_decode($special['contain_recipes_time']);
|
|
248
|
+ $idArr=array();
|
|
249
|
+ $today=date('Y-m-d');
|
|
250
|
+ foreach($contain_recipes_time as $key=>$value){
|
|
251
|
+ if($value < $today){
|
|
252
|
+ $idArr[]=$key;
|
|
253
|
+ }
|
|
254
|
+ }
|
|
255
|
+ $lastarr=explode(',',$special['contain_recipes']);
|
|
256
|
+ $idArr=array_intersect_assoc($idArr,$lastarr);
|
|
257
|
+ }else{
|
|
258
|
+ $idArr=explode(',',$special['contain_recipes']);
|
|
259
|
+ }
|
|
260
|
+ $menuList=Menu::whereIn('id',$idArr)->get();
|
|
261
|
+ return $this->response->array(self::returnValue(['data' => $menuList], 200));
|
|
262
|
+ }
|
|
263
|
+
|
|
264
|
+ public function menuDetail(Request $request){
|
|
265
|
+ $id=$request->input('id');
|
|
266
|
+ $menu=Menu::where('id',$id)->first();
|
|
267
|
+ $init=array();
|
|
268
|
+ $list=explode(',',$menu['ingredients']);
|
|
269
|
+ foreach($list as $item){
|
|
270
|
+ $origin=explode(':',$item);
|
|
271
|
+ $init[$origin[0]]=$origin[1];
|
|
272
|
+ }
|
|
273
|
+ $menu['ingredients']=$init;
|
|
274
|
+ $menuDetail=DB::table('menu_step')->where('menu_id',$id)->get();
|
|
275
|
+ return $this->response->array(self::returnValue(['data' => $menu,'detailData'=>$menuDetail], 200));
|
|
276
|
+ }
|
|
277
|
+
|
|
278
|
+ public function articleList(Request $request){
|
|
279
|
+ $page=$request->has('page')?$request->input('page'):1;
|
|
280
|
+ $start=intval((intval($page)-1)*intval(20));
|
|
281
|
+ $data=News::where('status',1)->select('id','imgurl','title','createTime')->orderBy('createTime','desc')->offset($start)->limit(20)->get();
|
|
282
|
+ return $this->response->array(self::returnValue(['data' => $data], 200));
|
|
283
|
+ }
|
|
284
|
+ public function articleDetail(Request $request){
|
|
285
|
+ $id=$request->input('id');
|
|
286
|
+ $articleDetail=News::where('id',$id)->first();
|
|
287
|
+ $articleDetail['content'] = str_replace(array("\r\n", "\r", "\n"), "", $articleDetail['content']);
|
|
288
|
+ return $this->response->array(self::returnValue(['data' => $articleDetail], 200));
|
|
289
|
+ }
|
191
|
290
|
}
|