public static function edit(array $args) { $arrName = ['username' => $args['username']]; $arrColl = ['college' => $args['college'], 'address' => $args['address']]; $user = User::find($args['id']); $info = $user->hasInfo; $allGoods = Goods::where('username', $user->username)->get(); if ($user->update($arrName) && $info->update($arrColl)) { if ($allGoods) { foreach ($allGoods as $aGoods) { $aGoods->update($arrName); } } $user = User::find($args['id']); $info = $user->hasInfo; $data = ['id' => $user->id, 'name' => $user->username, 'college' => $info->college, 'address' => $info->address]; return self::success($data); } return self::fail(); }
public static function newsCount($id, $username) { $sentNum = Goods::where(['username' => $username, 'is_send' => 1, 'status' => 0])->count(); $mesNum = self::where(['receiver_id' => $id, 'status' => 0])->count(); return ['sentNum' => $sentNum, 'mesNum' => $mesNum]; }
/** * 修改商品信息 * * @return Response */ public function postChangeStatus() { // return Input::all(); $shopID = base64_decode(Input::get('shop_id')); $headerShop = AuthController::checkShop($shopID); $goodsID = base64_decode(Input::get('goods_id')); $goodsStatus = Input::get('goods_status'); $goods = Goods::where('wy_goods_id', $goodsID)->where('wy_shop_id', $shopID)->where('wy_goods_state', '!=', $goodsStatus)->first(array('wy_goods_id', 'wy_goods_state', 'wy_onsale_time', 'wy_unsale_time')); $retCode = SUCCESS; $retMsg = ""; if (empty($goods)) { $retCode = -10050; $retMsg = Lang::get('errormessages.-10050'); $context = array("errorCode" => $retCode, "userID" => Auth::id(), "shopID" => $shopID, "goodsID" => $goodsID); Log::error($retMsg, $context); } else { $goods->wy_goods_state = $goodsStatus; if (GOODS_STATUS_1 == $goodsStatus) { $goods->wy_onsale_time = Carbon::now(); } elseif (GOODS_STATUS_2 == $goodsStatus) { $goods->wy_unsale_time = Carbon::now(); } $result = $goods->save(); if ($result) { $retMsg = Lang::get('messages.10012'); } else { $retCode = -15018; $retMsg = Lang::get('errormessages.-15018'); $context = array("errorCode" => $retCode, "userID" => Auth::id(), "shopID" => $shopID, "goodsID" => $goodsID, "goodsStatus" => $goodsStatus); Log::error($retMsg, $context); } } $sendMsgArray = array("ret_code" => $retCode, "msg" => $retMsg); return Response::json($sendMsgArray); }