示例#1
0
 /**
  * Post edit balance.
  * POST  /shop-admin/edit-balance/{id}
  *
  * @param  $id,UserInterface $userRepo,Request $request
  *
  * @return view
  */
 public function postEditBalance($id, UserInterface $userRepo, Request $request)
 {
     $data = $request->all();
     $validator = Validator::make($data, ['balance' => 'required|integer', 'percent' => 'required']);
     if ($validator->fails()) {
         return redirect()->back()->with(['error_danger' => trans('common.error_balance')]);
     }
     $user = $userRepo->getOne($id);
     $dataUpdate['balance'] = $user->balance + $data['balance'] * $data['percent'] * 0.01;
     $result = $userRepo->updateOne($id, $dataUpdate);
     return redirect()->action('ShopController@getDashboard')->with(['error' => trans('common.error_success_balance')]);
 }
示例#2
0
 public function postShoppingProduct(Request $request, ShoppingInformationInterface $infoRepo, UserInterface $userRepo, ProductInterface $productRepo)
 {
     $data = $request->all();
     if ($request->get('price') > Auth::user()->balance) {
         return redirect()->back()->with('error_danger', 'Դուք չունեք բավարար գումար գնում կատարելու համար');
     }
     $productsId = explode(',', $data['idsProduct']);
     unset($productsId[0]);
     $infosId = explode(',', $data['idsInfo']);
     unset($infosId[0]);
     foreach ($productsId as $productId) {
         $product = $productRepo->getOne($productId);
         $count = $product->count - 1;
         $result = $productRepo->update(['count' => $count], $productId);
     }
     foreach ($infosId as $infoId) {
         $result = $infoRepo->update(['shopping' => 'Yes'], $infoId);
     }
     $balance = Auth::user()->balance - $data['price'];
     $result = $userRepo->updateOne(Auth::user()->id, ['balance' => $balance]);
     return redirect()->back()->with('error', 'Ձեր գործարքը հաջողությամբ կատարվեց');
 }
示例#3
0
 /**
  * Post add new user.
  * POST  /admin/add-user/{id}
  *
  * @param  UserInterface $userRepo,UserInterface $request
  *
  * @return view
  */
 public function postAddUser(UserCreateRequest $request, UserInterface $userRepo)
 {
     $data = $request->inputs();
     if ($data['profile_picture'] != "") {
         $path = public_path() . '/uploads/images/';
         $name = str_random();
         $logoFile = $request->file('profile_picture')->getClientOriginalExtension();
         $result = $request->file('profile_picture')->move($path, $name . '.' . $logoFile);
         $data['profile_picture'] = $name . '.' . $logoFile;
     }
     $userKey = rand(1111111111, 9999999999);
     $data['user_key'] = $userKey;
     $user = $userRepo->createOne($data);
     return redirect()->action('AdminController@getUsers');
 }