/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { // // 先验证 $this->validate($request, ['title' => 'required', 'content' => 'required']); // $wdInfo = WdInfo::findOrFail($id); $wdInfo->title = Input::get('title'); $wdInfo->content = Input::get('content'); // 单独处理图片 $newLogo = ImageUtil::saveImgFromRequest($request, 'logo', 'img/wd/'); if (!is_null($newLogo)) { $wdInfo->logo = $newLogo; } $newQr = ImageUtil::saveImgFromRequest($request, 'qrImg', 'img/wd/'); if (!is_null($newQr)) { $wdInfo->qr_img = $newQr; } if ($wdInfo->save()) { // return redirect($request->getPathInfo(). '/edit')->withData([ // 'wdInfo' => $wdInfo, // 'message' => [trans('adminTip.wdInfo.editInfo.success.edit')] // ]); return redirect($request->getPathInfo() . '/edit')->withInput()->withOk(trans('adminTip.wdInfo.editInfo.success.edit')); } else { return Redirect::back()->withInput()->withErrors('error'); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { // return view("wd.index")->withData(['menu' => Menu::all(), 'products' => $this->doSearchByCategory(WDConfig::PRODUCT_CATEGORY_JIEMIAN), 'wdInfo' => WdInfo::find(1)]); }