Exemplo n.º 1
0
 public function saveaddr(Request $request)
 {
     header("Content-Type:text/html;charset=utf-8");
     //  $addrid=$request->input("myaddr");
     //  echo "addrid=".$addrid;
     //   var_dump($_POST);exit();
     $addrid = $request->input("myaddr");
     //如果不是已经选好的地址,就是新增
     if ($addrid) {
         $demand = Demand::findOrFail($request->input("deid"));
         if ($demand != null) {
             $demand->addrid = $addrid;
             $demand->save();
             return "保存地址成功";
         } else {
             echo "参数错误未找到订单";
             exit;
         }
     }
     $addr = new Address();
     $send = $request->input('send');
     $addr->user_id = Auth::user()->id;
     $addr->name = $send['name'];
     //$addr->title=$send['title'];
     // $addr->telephone=$send['telephone'];
     // $addr->zipcode=$send['zipcode'];
     $addr->province = $request->input('province');
     $addr->city = $request->input('city');
     $addr->mobile = $send['mobile'];
     $addr->area_id = $request->input("district");
     $addr->addr_detail = $request->input('addr_detail');
     $onearea = Area::select("areaname")->where("id", '=', $addr->province)->get()->first();
     $provincename = $onearea->areaname;
     $onearea = Area::select("areaname")->where("id", '=', $addr->city)->get()->first();
     $cityname = $onearea->areaname;
     $addr->fulladdr = $provincename . " " . $cityname . " " . $addr->addr_detail;
     $addr->is_default = 1;
     $addr->save();
     $demand = Demand::findOrFail($request->input("deid"));
     $demand->addrid = $addr->id;
     $demand->save();
     //保存订单的地址
     //  return "保存地址成功";
     return Redirect::to('demand/my')->withErrors('保存地址成功!');
 }
Exemplo n.º 2
0
 public function area(Request $request)
 {
     $area = Area::select("id", "areaname")->where("parent_id", '=', $request->input('areaid'))->get();
     return json_encode($area);
 }