public function bets() { $param = Input::only('account_id', 'bets'); $rules = array('bets' => 'required|numeric|min:1,max:1000000', 'account_id' => 'required|exists:acl_users,id'); //custom error messaging $messages = array('buyer_id.exists' => 'Buyer id is not valid.', 'merchant_id.exists' => 'Merchant id is not valid'); $validator = Validator::make($param, $rules, $messages); if ($validator->passes()) { $points_conversion = Settings::getSettingValue('points_conversion'); $points_converted = $param['bets'] / floatval($points_conversion); $create = array('account_id' => $param['account_id'], 'added_by' => $this->operator_id, 'bet' => $param['bets'], 'points_conversation' => floatval($points_conversion), 'points_converted' => $points_converted); try { $player_bet = Playerbets::create($create); $retrieve = Points::where('account_id', $param['account_id'])->first(); $update = $retrieve->increment('credits', $points_converted); $message = 'Points has been updated.'; return Redirect::action('points.player')->with('success', $message); } catch (Exception $e) { // return false; print $e; } } else { $messages = $validator->messages(); return Redirect::action('points.player')->with('error', $messages->all()); } }
public function post() { $param = Input::only('player_id', 'points'); $rules = array('points' => 'required|numeric|min:1,max:1000000', 'player_id' => 'required|exists:acl_users,id'); //custom error messaging $messages = array('points.required' => 'Please fill up the player points redemption.', 'merchant_id.exists' => 'Merchant id is not valid'); $validator = Validator::make($param, $rules, $messages); if ($validator->passes()) { $player_points = Points::where('account_id', $param['player_id'])->get()->first(); $param = array('player_id' => $param['player_id'], 'points' => $param['points'], 'redeem_by' => Auth::user()->id, 'coupon_code' => Utils::generateRandomString(), 'redeemed' => 1); try { $player_bet = Coupon::create($param); $update = $player_points->decrement('credits', $param['points']); $message = 'Points has been successfully redeemed.'; return Redirect::action('points.redeem')->with('success', $message); } catch (Exception $e) { print $e; } } else { $messages = $validator->messages(); return Redirect::action('points.redeem')->with('error', $messages->all()); } }