/**
  *
  * @SWG\Api(
  *   path="/home_navigation",
  *   description="首页按钮和banner",
  *   @SWG\Operation(
  *     method="GET", summary="获得首页和banner按钮列表", notes="对于按钮列表点击详情时:当type=0的时候调用 APP WAP 页 中的导航按钮详情图片接口来访问详情,当type=1时,直接跳转action字段中的链接",
  *     type="HomeNavigationAndBanner",
  *     @SWG\ResponseMessage(code=0, message="成功")
  *   )
  * )
  */
 public function index(Request $request)
 {
     $response = new BaseResponse();
     $ret = (object) null;
     $button_list = HomeNavigation::orderBy('sort')->orderBy('id')->get();
     $banners = Banner::where('banner_position', 0)->get();
     $ret->button_list = $button_list;
     $ret->banner_list = $banners;
     $response->Data = $ret;
     return $response->toJson();
 }
 public function update(Request $request, $id)
 {
     $params = $request->all();
     $homeNavigation = HomeNavigation::find($id);
     if ($homeNavigation != null) {
         if ($homeNavigation->id == 1) {
             $homeNavigation->title = $params['titleNew'];
             $homeNavigation->subhead = $params['subheadNew'];
             $homeNavigation->save();
             HomeButtonGoods::where('home_button_id', $homeNavigation->id)->delete();
             $items = substr($params['item_id'], 0, strlen($params['item_id']) - 1);
             $items = explode(',', $items);
             foreach ($items as $v) {
                 $homeButtonGoods = new HomeButtonGoods();
                 $homeButtonGoods->home_button_id = $homeNavigation->id;
                 $homeButtonGoods->goods_id = $v;
                 $homeButtonGoods->save();
             }
             return redirect()->action('Admin\\HomeNavigationController@show');
         }
         if ($params['type'] == 0) {
             unset($params['action']);
             if ($request->hasFile('coverImage')) {
                 $file = $request->file('coverImage');
                 $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension();
                 $file->move(base_path() . '/public/upload', $fileName);
                 $params['path'] = '/upload/' . $fileName;
             }
         }
         unset($params['coverImage']);
         unset($params['_token']);
         foreach ($params as $n => $p) {
             $homeNavigation->{$n} = $p;
         }
         $homeNavigation->save();
     }
     return redirect()->action('Admin\\HomeNavigationController@show');
 }
示例#3
0
 /**
  *
  * @SWG\Api(
  *   path="/wap/home_navigation_detail/{id}",
  *   @SWG\Operation(
  *     method="GET", summary="导航按钮详情图片", notes="导航按钮详情图片",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="id",
  *         paramType="path",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer",
  *     )
  *
  *   )
  * )
  */
 public function homeNavigationDetail($id)
 {
     $data['homeNavigation'] = HomeNavigation::find($id)->toArray();
     return view('wap.home_navigation_detail', $data);
 }