/** * Display options for filtering attendance list. * * @return Response */ public function showFilterOptions() { $sites = Site::where('id', '>', 1)->get()->lists('code', 'id')->toArray(); $trades = Trade::all()->lists('name', 'id')->toArray(); array_unshift($trades, ""); //dd($trades); return view('pages.filteroptions', compact('sites', 'trades')); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('trade')->delete(); DB::table('diary')->delete(); Trade::create(['name' => '支付中研院場地租金', 'handler' => '劉彥君', 'comment' => '跟歷年一樣的金額', 'event_id' => 1, 'user_id' => 1, 'trade_at' => '2015-12-31']); Diary::create(['direction' => true, 'amount' => 1000, 'trade_id' => 1, 'account_id' => 1, 'account_parent_id' => 111]); Diary::create(['direction' => false, 'amount' => 1000, 'trade_id' => 1, 'account_id' => 7, 'account_parent_id' => 211]); }
public function finish() { $legacyNum = Input::get('id'); $sellerId = Session::get(MateMiddleware::$VERIFY); $legacy = Legacy::find($legacyNum); if ($legacy->owner->id != $sellerId) { return 'invalid'; } DB::beginTransaction(); Trade::create(['id' => $legacy->id, 'buyer' => Input::get('buyer'), 'seller' => $sellerId, 'description' => $legacy->des, 'img' => $legacy->img]); $legacy->delete(); DB::commit(); return 'success'; }
public function CompleteTrade() { $userRep = new UsersRepository(); $portfolioRep = new PortfoliosRepository(); $id = Input::get('id'); $user = Auth::user(); if ($user) { $trade = Trade::find($id); $portfolio = Portfolio::find($trade->portfolio_id); if ($portfolio->user_id == Auth::user()->id && $trade->is_active) { $profile = Profile::find($trade->profile_id); $trade->is_active = false; $trade->price_sold = $profile->current_price; $trade->save(); $price = $profile->current_price * $trade->shares_taken; $portfolioRep->IncreaseBalance($portfolio, $price); return response()->json(array('success' => true, 'portfolioId' => $portfolio->id, 'price' => $price)); } } return response()->json(array('success' => false)); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $labor = Labor::where('employee_no', '=', $id)->first(); $trades = Trade::all()->lists('name', 'id')->toArray(); $sites = Site::all()->lists('code', 'id')->toArray(); //dd($trades); return view('pages.edit_labor', compact('labor', 'sites', 'trades')); }
public function GetActiveProfileTrades($profile_id) { return Trade::where('profile_id', $profile_id)->where('is_active', true)->get(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $trade = Trade::where('name', '=', $id)->first(); if ($trade == null) { return redirect('trades'); } $trade->delete(); return redirect('trades'); }
public function findOpenPosition($comparable, $compare_string) { $trades = Trade::where($compare_string, $comparable)->get(array('id', 'price', 'symbol', 'contract', 'lots', 'order_type')); $trades_1 = $trades; foreach ($trades as $trade) { $total_lots = abs($trade->lots); $open_lots = $trade->lots; $avg_price = null; $avg_buy = null; $avg_sell = null; $sum_buy_trades = array(); $sum_sell_trades = array(); $sum_abs_lots_price = array(); $sum_buy_lots_price = array(); $sum_sell_lots_price = array(); if ($trade->lots < '0') { array_push($sum_sell_trades, $trade->lots); array_push($sum_sell_lots_price, $trade->lots * $trade->price); } elseif ($trade->lots > '0') { array_push($sum_buy_trades, $trade->lots); array_push($sum_buy_lots_price, $trade->lots * $trade->price); } array_push($sum_abs_lots_price, abs($trade->lots) * $trade->price); //loop through rest of trades and store key numbers for trades with same contract as $trade foreach ($trades_1 as $trade_1) { if ($trade->contract === $trade_1->contract && $trade->id !== $trade_1->id) { $total_lots = $total_lots + abs($trade_1->lots); $open_lots = $open_lots + $trade_1->lots; if ($trade_1->lots < '0') { array_push($sum_sell_trades, $trade_1->lots); array_push($sum_sell_lots_price, $trade_1->lots * $trade_1->price); } elseif ($trade_1->lots > '0') { array_push($sum_buy_trades, $trade_1->lots); array_push($sum_buy_lots_price, $trade_1->lots * $trade_1->price); } array_push($sum_abs_lots_price, abs($trade_1->lots) * $trade_1->price); } } $closed_lots = $total_lots - $open_lots; foreach ($sum_abs_lots_price as $abs_profit) { $avg_price = $abs_profit + $avg_price; } $avg_price = $avg_price / $total_lots; ///////BUY SIDE ////// $buyside_profits = null; foreach ($sum_buy_lots_price as $buy_profit) { $buyside_profits = $buyside_profits + $buy_profit; } $buyside_lots = null; foreach ($sum_buy_trades as $buy_lots) { $buyside_lots = $buyside_lots + $buy_lots; } if ($buyside_lots != 0) { $avg_buy = $buyside_profits / $buyside_lots; } ///////SELL SIDE ///// $sellside_profits = null; foreach ($sum_sell_lots_price as $sell_profit) { $sellside_profits = $sellside_profits + $sell_profit; } $sellside_lots = null; foreach ($sum_sell_trades as $sell_lots) { $sellside_lots = $sellside_lots + $sell_lots; } if ($sellside_lots != 0) { $avg_sell = $sellside_profits / $sellside_lots; } $market_price = $avg_price + rand(-100, 100) / 100; $trade['total_lots'] = $total_lots; $trade['open_lots'] = $open_lots; $trade['closed_lots'] = $closed_lots; $trade['avg_sell'] = $avg_sell; $trade['avg_buy'] = $avg_buy; $trade['avg_price'] = $avg_price; $trade['market_price'] = $market_price; unset($trade['id']); unset($trade['price']); unset($trade['lots']); unset($trade['symbol']); unset($trade['order_type']); } return $trades; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $trades = Trade::findorFail($id); $trades->delete(); return redirect('admin/trade'); }
public function deleteEventDiary(Request $request, $eventId) { $validator = Validator::make(['event_id' => $eventId, 'trade_id' => $request->get('trade_id')], ['event_id' => 'required|exists:event,id', 'trade_id' => 'required|exists:trade,id']); if ($validator->fails()) { return redirect()->route('event::diary', ['eventId' => $eventId, 'page' => $request->get('current_page')])->with('errors' . $request->get('trade_id'), $validator->messages()); } else { // save the trade name $deleteTrade = Trade::find($request->get('trade_id'))->name; $transaction = DB::transaction(function () use($request, $eventId) { // delete the relate file's $files = DiaryAttachedFiles::where('event_id', '=', $eventId)->where('trade_id', '=', $request->get('trade_id'))->get(); foreach ($files as $file) { // Storage::delete(join(DIRECTORY_SEPARATOR, ['diary', $file->event_id, $file->trade_id, $file->file_name])); $file->delete(); } // delete the relate diarys $diarys = Trade::find($request->get('trade_id'))->diary; foreach ($diarys as $diary) { $diary->delete(); } // delete the trade Trade::find($request->get('trade_id'))->delete(); }); Cache::forget('tradeList-' . $eventId . '-' . $request->get('current_page')); if (is_null($transaction)) { Session::flash('toast_message', ['type' => 'success', 'content' => '成功刪除交易「' . $deleteTrade . '」']); return redirect()->route('event::diary', ['eventId' => $eventId, 'page' => $request->get('current_page')]); } else { Session::flash('toast_message', ['type' => 'error', 'content' => '刪除交易「' . $deleteTrade . '」失敗']); return redirect()->route('event::diary', ['eventId' => $eventId, 'page' => $request->get('current_page')]); } } }
@extends('front.frontmaster') @section('content') <?php use App\Trade; $trades = Trade::latest()->get(); ?> @foreach($trades as $trade ) <h2>{{$trade->title}}</h2> <p>{!!$trade->details!!}</p> @endforeach @endsection