public function add(Request $request)
 {
     $this->validate($request, Demand::addRules());
     $demand = new Demand();
     $demand->user_id = Auth::user()->id;
     if ($request->get('esCate') != 0) {
         $demand->category_id = $request->get('esCate');
     } else {
         if ($request->get('sCate') == 0) {
             $demand->category_id = $request->get('fCate');
         } else {
             $demand->category_id = $request->get('sCate');
         }
     }
     $helper = new Helper();
     $demand->sn = 'DE' . time() . $helper->mt_rand_str(4, '0123456789');
     //单号算法:DE+当前时间戳10位数字+4位随机数
     $demand->url = $request->get('url');
     $demand->title = $request->get('title');
     $demand->price = $request->get('price');
     $demand->ip = $_SERVER["REMOTE_ADDR"];
     $cate2 = Category::find($demand->category_id);
     $demand->cat2 = $cate2->parent_id;
     $cate1 = Category::find($cate2->parent_id);
     $demand->cat1 = $cate1->parent_id;
     $demand->cat3 = $request->get("esCate");
     $demand->bid = $request->get("esbrand");
     //品牌的ID
     //    $demand->expire_time = $request->get('expire_time');这个从支付时间算起
     $demand->avltime = intval($request->get('avltime'));
     $demand->expire_time = date("Y-m-d H:i:s", strtotime("+ " . $demand->avltime . " hours"));
     //设置过期时间,
     $demand->addtime = date("Y-m-d H:i:s");
     $demand->details = $request->get('details');
     $demand->status = 0;
     //表示审核中
     $helper = new Helper();
     $demand->thumb = $helper->get_thumb($request->get('thumb'));
     $demand->save();
     //return Redirect::to('demand/show/'.$demand->id);
     return Redirect::to('/pay/deposit/' . $demand->id);
 }