/** * 检查用户是否有配送信息 * * @param int $uid * @return bool */ public static function shipping($uid = 0) { $ret = false; if ($uid) { $shipping = PhoneUserShipping::where(['user_id' => $uid])->first(); if ($shipping) { $ret = $shipping; } } return $ret; }
public function update($id) { if ($id) { $callback = Input::get('callback', null); if ($callback) { CallBack::set($callback); } $name = Input::get('name', null); $province = Input::get('province', null); $city = Input::get('city', null); $district = Input::get('district', null); $address = Input::get('address', null); $zipcode = Input::get('zipcode', 0); $tel = Input::get('tel', 0); if (!$name) { flash('亲,真实姓名不能为空哦~请重试'); return redirect()->back(); } if (!$province or $province == '请选择省') { flash('亲,要选择您的所在省哦~请重试'); return redirect()->back(); } if (!$city or $province == '请选择市') { flash('亲,要选择您的所在市哦~请重试'); return redirect()->back(); } if (!$district or $district == '请选择区') { flash('亲,要选择您的所在区哦~请重试'); return redirect()->back(); } if (!$address) { flash('亲,收货地址不能为空哦~请重试'); return redirect()->back(); } if (!VerifyUser::zipCode($zipcode)) { flash('亲,邮政编码格式错误哦~请重试'); return redirect()->back(); } if (!VerifyUser::phoneCode($tel)) { flash('亲,手机号码格式错误哦~请重试'); return redirect()->back(); } $shipping = PhoneUserShipping::find($id); if ($shipping) { $shipping->name = $name; $shipping->province = $province; $shipping->city = $city; $shipping->district = $district; $shipping->address = $address; $shipping->zipcode = $zipcode; $shipping->tel = $tel; if ($shipping->save()) { if ($callback) { return redirect(CallBack::get()); } else { return redirect('my/shipping'); } } else { flash('亲,服务器现在压力山大~再试一下吧'); return redirect()->back(); } } else { flash('亲,服务器现在压力山大~再试一下吧'); return redirect()->back(); } } }