public function show() { $data['categories'] = Category::where('pid', 0)->get(); $data['activity_classification'] = ActivityClassification::all(); $data['free_post'] = FreePost::all(); return view('admin.goods.index', $data); }
public function update(Request $request, $id) { $params = $request->all(); $freepost = FreePost::find($id); if ($freepost != null) { if ($request->hasFile('coverImage')) { $file = $request->file('coverImage'); $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension(); $file->move(base_path() . '/public/upload', $fileName); $params['cover'] = '/upload/' . $fileName; } unset($params['coverImage']); if ($request->hasFile('headImage')) { $file = $request->file('headImage'); $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension(); $file->move(base_path() . '/public/upload', $fileName); $params['head_image'] = '/upload/' . $fileName; } unset($params['headImage']); unset($params['_token']); foreach ($params as $n => $p) { $freepost->{$n} = $p; } $freepost->save(); } return redirect()->action('Admin\\FreePostController@show'); }
/** * * @SWG\Api( * path="/activity_page", * description="约惠主页(有更新20160308)", * @SWG\Operation( * method="GET", summary="获得约惠主页内容", notes="获得约惠主页内容", * type="ActivityPage", * @SWG\ResponseMessage(code=0, message="成功"), * @SWG\Parameter( * name="user_id", * description="用户id", * paramType="query", * required=false, * allowMultiple=false, * type="integer", * defaultValue=-1 * ) * ) * ) */ public function index(Request $request) { $user_id = $request->input('user_id', -1); $response = new BaseResponse(); $ret = (object) null; $banners = Banner::where('banner_position', 1)->get(); $ret->banners = $banners; //分类 $activityClassification = ActivityClassification::all(); $ret->activityClassification = $activityClassification; //包邮 $freePost = FreePost::all(); $ret->freePost = $freePost; //爆品 $conversionGoods = ConversionGoods::all(); //$conversionGoods=$conversionGoods->toArray(); foreach ($conversionGoods as &$v) { $v->has_collection = 0; if ($user_id != -1) { $collection = Collection::where('user_id', $user_id)->where('type', 0)->where('item_id', $v->goods_id)->first(); if ($collection != null) { $v->has_collection = 1; } } } $ret->conversionGoods = $conversionGoods; $response->Data = $ret; return $response->toJson(); }
/** * * @SWG\Api( * path="/free_post/{id}", * description="包邮分类详情", * @SWG\Operation( * method="GET", summary="获得包邮分类详情", notes="获得包邮分类详情", * type="FreePostDetail", * @SWG\ResponseMessage(code=0, message="成功"), * @SWG\Parameter( * name="id", * description="分类id", * paramType="path", * required=true, * allowMultiple=false, * type="integer", * ) * ) * ) */ public function show(Request $request, $id) { $response = new BaseResponse(); $freePost = FreePost::find($id); $goods_list = FreePostGoods::where('free_posts_id', $id); $goods_list = $goods_list->orderBy('id', 'desc')->get(); $ret = (object) null; $ret->free_post = $freePost; $ret->goods_list = $goods_list; $response->Data = $ret; return $response->toJson(); }