コード例 #1
0
ファイル: GoodsController.php プロジェクト: ataiton/tyreplus
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     if (empty($this->authUser->role_id)) {
         return \Response::json(array('status' => 0, 'alerts' => 'Permission denied'));
     } elseif ($this->authUser->role_id != 1) {
         return \Response::json(array('status' => 0, 'alerts' => 'Permission denied'));
     }
     $input = array_except(\Input::all(), '_token');
     $input['updated_by'] = $this->authUser->user_id;
     Goods::where('goods_id', '=', $id)->update($input);
     return \Response::json(array('status' => 1));
 }
コード例 #2
0
ファイル: AdminController.php プロジェクト: ataiton/tyreplus
 public function orderGetGoods(Request $request)
 {
     if (empty($this->authUser)) {
         return \Response::json(array('status' => 0));
     } elseif ($this->authUser->role_id != 1 && $this->authUser->role_id != 4) {
         return \Response::json(array('status' => 0));
     }
     $order_sys = $request->session()->get('orderSystem', '');
     $input = \Input::all();
     switch ($input['type']) {
         case 'add':
             if (!empty($order_sys['itemData'])) {
                 foreach ($order_sys['itemData'] as $v) {
                     if ($input['pn'] == $v['supplier_product_code_part_number']) {
                         return \Response::json(array('status' => 0));
                     }
                 }
             }
             $goods = Goods::where('supplier_product_code_part_number', '=', $input['pn'])->first();
             if (!$goods) {
                 return \Response::json(array('status' => 0));
             }
             $goods = $goods->toArray();
             $goods['bucket_unit'] = 1;
             $order_sys['itemData'][] = $goods;
             $request->session()->put('orderSystem', $order_sys);
             break;
         case 'plus':
             if (!empty($order_sys['itemData'])) {
                 foreach ($order_sys['itemData'] as &$v) {
                     if ($input['pn'] == $v['supplier_product_code_part_number']) {
                         $v['bucket_unit']++;
                         $request->session()->put('orderSystem', $order_sys);
                         break;
                     }
                 }
             }
             break;
         case 'dis':
             if (!empty($order_sys['itemData'])) {
                 foreach ($order_sys['itemData'] as $key => &$v) {
                     if ($input['pn'] == $v['supplier_product_code_part_number']) {
                         if ($v['bucket_unit'] > 1) {
                             $v['bucket_unit']--;
                             $request->session()->put('orderSystem', $order_sys);
                         }
                         break;
                     }
                 }
             }
             break;
         case 'set':
             if (!empty($order_sys['itemData'])) {
                 foreach ($order_sys['itemData'] as $key => &$v) {
                     if ($input['pn'] == $v['supplier_product_code_part_number']) {
                         if ($input['num'] <= 0) {
                             $v['bucket_unit'] = 1;
                         } elseif ($input['num'] >= 10000) {
                             $v['bucket_unit'] = 9999;
                         } else {
                             $v['bucket_unit'] = $input['num'];
                         }
                         $request->session()->put('orderSystem', $order_sys);
                         break;
                     }
                 }
             }
             break;
         case 'del':
             if (!empty($order_sys['itemData'])) {
                 foreach ($order_sys['itemData'] as $key => $v) {
                     if ($input['pn'] == $v['supplier_product_code_part_number']) {
                         unset($order_sys['itemData'][$key]);
                         $order_sys['itemData'] = array_values($order_sys['itemData']);
                         $request->session()->put('orderSystem', $order_sys);
                         break;
                     }
                 }
             }
             break;
     }
     //$request->session()->put('orderSystem','');
     return \Response::json(array('status' => 1, 'itemData' => $order_sys['itemData']));
 }
コード例 #3
0
 public function personal(Request $request)
 {
     $result = $this->check($request);
     $entrance = $request->input('entrance');
     $user = Info::where('user_id', $result['loginFlag'])->first();
     $user->username = $result['username'];
     $user->src = 'uploads/' . $user->head_photo;
     $news = Comments::newsCount($result['loginFlag'], $result['username']);
     if (!$result['loginFlag']) {
         return redirect('/');
     }
     if ($entrance == 'sending') {
         $status = 1;
         $data = Goods::personal($result['loginFlag'], 8, $entrance);
     } elseif ($entrance == 'info') {
         $status = 2;
         $data = Comments::personal($result['loginFlag'], 8);
     } else {
         $status = 0;
         $data = Goods::personal($result['loginFlag'], 8, 'sent');
     }
     $goods = Goods::where(['username' => $result['username'], 'is_send' => 1, 'status' => 0])->first();
     if ($goods) {
         $goods->update(['status' => 1]);
     }
     return view('pc.personal', ['key' => '', 'loginFlag' => $result['loginFlag'], 'username' => $result['username'], 'sentNum' => $news['sentNum'], 'mesNum' => $news['mesNum'], 'max' => $data['maxPage'], 'status' => $status, 'user' => $user, 'data' => $data['data']]);
 }