コード例 #1
0
ファイル: MainController.php プロジェクト: andycall/haochigou
 /**
  * 收藏某个店铺
  * 请求类型:POST
  */
 public function collectShop()
 {
     $user = Auth::user();
     $rules = array('uid' => 'required | integer | exists:front_user,front_uid', 'shop_id' => 'required | integer | exists:shop,id');
     $new_collect = array('uid' => $user->front_uid, 'shop_id' => Input::get('shop_id'), 'uptime' => time());
     $v = Validator::make($new_collect, $rules);
     if ($v->fails()) {
         $message = $v->messages();
         return json_encode(array('success' => 'false', 'state' => 400, 'errMsg' => $message->toArray(), 'no' => 1));
     }
     $collect = new CollectShop($new_collect);
     if ($collect->save()) {
         $output = array('success' => 'true', 'state' => 200, 'nextSrc' => '', 'errMsg' => '', 'no' => 0);
         $stores = $this->getMyStore();
         $output['data']['collection_shop'] = $stores['data'];
         return $output;
     }
 }
コード例 #2
0
 /**
  * 收藏某个店铺
  *
  * 请求类型:POST
  */
 public function collectShop()
 {
     if (!Auth::check()) {
         return Redirect::to('http://weibo.com');
     }
     $user = Auth::user();
     $rules = array('uid' => 'required | integer | exists:front_user,front_uid', 'shop_id' => 'required | integer | exists:shop,id');
     $new_collect = array('uid' => $user->front_uid, 'shop_id' => Input::get('shop_id'), 'uptime' => time());
     $v = Validator::make($new_collect, $rules);
     if ($v->fails()) {
         return Redirect::to('http://baidu.com');
         return Redirect::to('error')->with('user', Auth::user())->withErrors($v)->withInput();
     }
     $collect = new CollectShop($new_collect);
     if ($collect->save()) {
         $output = array();
         $output['success'] = 'true';
         $output['state'] = 200;
         $output['nextSrc'] = '';
         $output['errMsg'] = '';
         $output['no'] = 0;
         $output['data'] = $this->getShopInfo(Input::get('shop_id'));
         //var_dump($output);
         Response::json($output);
     }
 }
コード例 #3
0
 /**
  * 收藏某个店铺
  *
  * 请求类型:POST
  */
 public function collectShop()
 {
     $user = Auth::user();
     $rules = array('uid' => 'required | integer | exists:front_user,front_uid', 'shop_id' => 'required | integer | exists:shop,id');
     $new_collect = array('uid' => $user->front_uid, 'shop_id' => Input::get('shop_id'), 'uptime' => time());
     $v = Validator::make($new_collect, $rules);
     if ($v->fails()) {
         $message = $v->messages();
         return json_encode(array('success' => false, 'state' => 400, 'errMsg' => $message->toArray(), 'no' => 1));
     }
     $collect = new CollectShop($new_collect);
     if ($collect->save()) {
         $output = array();
         $output['success'] = 'true';
         $output['state'] = 200;
         $output['nextSrc'] = '';
         $output['errMsg'] = '';
         $output['no'] = 0;
         $output['data'] = $this->getShopInfo(Input::get('shop_id'));
         //var_dump($output);
         Response::json($output);
     }
 }