public function postEdit(Exchange $exchange) { $rules = array('name' => 'required|max:32', 'description' => 'max:1024', 'draw_at' => '', 'give_at' => '', 'passphrase' => 'required|min:3|max:32', 'spending_limit' => 'required|integer|min:1|max:999'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route('exchange.edit', ['exchange' => $exchange->slug])->withErrors($validator)->withInput(Input::all()); } else { $exchange->name = Input::get('name'); if (Input::has('description')) { $exchange->description = Input::get('description'); } $exchange->spending_limit = Input::get('spending_limit'); $exchange->passphrase = Input::get('passphrase', null); if (Input::has('hidden')) { $exchange->hidden = true; } $exchange->save(); return Redirect::route('exchange', ['exchange' => $exchange->slug]); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $s_product_id = Input::get('s_product_id'); $s_user_id = Session::get('current_user'); $r_product_id = Session::get('r_product_id'); $r_users_id = Product::find($r_product_id)->user->id; $exchange = new Exchange(); $exchange->s_product_id = $s_product_id; $exchange->r_product_id = $r_product_id; $exchange->s_user_id = $s_user_id; $exchange->r_user_id = $r_users_id; $exchange->status = 0; if ($exchange->save()) { Session::flash('status', true); Session::flash('messages', array('Đã gửi')); } else { Session::flash('status', false); Session::flash('messages', array('Đã xảy ra lỗi khi gửi yêu cầu trao đổi')); } return Redirect::to('/'); }
public static function updatePrices($pair = 'btc_rur') { $BTCeAPI = BTCeAPI::get_Instance(); $ticker = $BTCeAPI->getPairTicker($pair); $ticker = $ticker['ticker']; $exchange = new Exchange(); $exchange->buy = $ticker['buy']; $exchange->sell = $ticker['sell']; $exchange->dtm = date('Y-m-d H:i:s', $ticker['updated']); $exchange->pair = $pair; $exchange->save(); return $exchange; }