public function getShow($gameId) { $game = Game::findOrFail($gameId); $account = Account::where('user_id', '=', Auth::user()->id)->where('game_id', '=', $gameId)->first(); $servers = $game->servers()->paginate(10); return view('game.show', ['game' => $game, 'account' => $account, 'servers' => $servers, 'page_title' => 'Game Detail']); }
public function getCreate(Request $request) { $accounts = \App\Account::where('user_id', '=', \Auth::id())->find($request->id); $transactions = new \App\Transaction(); $categories = ['Deposit/Credit', 'Automobile', 'Groceries', 'Health & Beauty', 'Home Improvement', 'Meals & Entertainment', 'Medical Expense', 'Utilities', 'Insurance', 'Miscellaneous']; return view('transaction.create')->with('transactions', $transactions)->with(['categories' => $categories])->with('accounts', $accounts); }
public function index(Request $request) { $this->validate($request, ['month' => 'required', 'year' => 'required']); $month = $request->month; $year = $request->year; $monthNum = $request->month; $monthName = date("F", mktime(0, 0, 0, $monthNum, 10)); $data = DB::select("SELECT users.id, users.name , users.picture, users.room_id,\n SUM(CASE WHEN bookings.breakfast='on' THEN 1 ELSE 0 END) AS t_b ,\n SUM(CASE WHEN bookings.lunch='on' THEN 1 ELSE 0 END) AS t_l ,\n SUM(CASE WHEN bookings.dinner='on' THEN 1 ELSE 0 END) AS t_d FROM `users`\n INNER JOIN\n `bookings` ON users.id=bookings.user_id AND\n MONTH(bookings.bookingdate) = {$month} AND\n YEAR(bookings.bookingdate) = {$year}\n\n GROUP BY users.id\n ORDER BY users.room_id ASC"); $datas = []; $data = json_decode(json_encode($data), true); foreach ($data as $key => $value) { $x = []; $x = $value; $x['exp'] = Account::where('user_id', $x['id'])->whereMonth('accountdate', '=', $month)->whereYear('accountdate', '=', $year)->sum('amount'); $datas[] = $x; } $total_t_b = $total_t_l = $total_t_d = $total_exp = 0; foreach ($datas as $data) { $total_t_b += $data['t_b']; $total_t_l += $data['t_l']; $total_t_d += $data['t_d']; $total_exp += $data['exp']; } $g_total = $total_t_b + $total_t_l + $total_t_d; if ($g_total <= 0) { $perbookingprice = 0; } else { $perbookingprice = $total_exp / $g_total; } return view('summary.index', ['datas' => $datas, 'total_t_b' => $total_t_b, 'total_t_l' => $total_t_l, 'total_t_d' => $total_t_d, 'total_exp' => $total_exp, 'g_total' => $g_total, 'perbookingprice' => $perbookingprice, 'year' => $year, 'monthName' => $monthName, 'month' => $month, 'year' => $year]); }
public function deleteAccount(Request $request) { $this->validate($request, ['id' => 'required|exists:account,id', 'parent_id' => 'required|exists:account,parent_id']); // Check the account whether has the pareant $checkParent = Account::where('parent_id', '=', $request->get('parent_id') . $request->get('id'))->first(); // Save the account name $query = DB::table('account')->where('id', '=', $request->get('id'))->where('parent_id', '=', $request->get('parent_id')); $deleteAccountName = $query->get()[0]->name; if ($checkParent === null) { // Check the account whether be used in Diary $checkDiary = DB::select('select * from diary where account_id = :accountId and account_parent_id = :accountParentId', ['accountId' => $request->get('id'), 'accountParentId' => $request->get('parent_id')]); if (empty($checkDiary)) { $result = $query->delete(); if ($result) { Cache::forget('accountList'); Session::flash('toast_message', ['type' => 'success', 'content' => '成功刪除會計科目「' . $deleteAccountName . '」']); return redirect()->route('account::main'); } else { Session::flash('toast_message', ['type' => 'error', 'content' => '刪除會計科目「' . $deleteAccountName . '」失敗']); return redirect()->route('account::main'); } } else { Session::flash('toast_message', ['type' => 'warning', 'content' => '刪除會計科目「' . $deleteAccountName . '」失敗(無法刪除已使用科目)']); return redirect()->route('account::main'); } } else { Session::flash('toast_message', ['type' => 'warning', 'content' => '刪除會計科目「' . $deleteAccountName . '」失敗(無法刪除父科目)']); return redirect()->route('account::main'); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $price = Account::whereMonth('accountdate', '=', date('m'))->where('user_id', Auth::user()->id)->sum('amount'); $items = Item::lists('item', 'item'); $itemname = Item::all(); $accounts = Account::where('user_id', Auth::user()->id)->orderBy('accountdate', 'desc')->paginate(10); return view('accounts.index', ['accounts' => $accounts, 'items' => $items, 'itemname' => $itemname, 'price' => $price]); }
public function getAccountInfo($id) { $account = Account::where('id', $id)->with('roles.permissions', 'activitySettings.pitches')->with(['activitySettings.elevationItems' => function ($query) { $query->where('type', 'elevation'); }])->with(['activitySettings.salesItems' => function ($query) { $query->where('type', 'sales'); }])->with(['activitySettings.leadDataItems' => function ($query) { $query->where('type', 'lead_data'); }])->get(); return $account; }
public function getEdit($id = null) { $accounts = \App\Account::where('user_id', '=', \Auth::id())->find($id); if (is_null($accounts)) { \Session::flash('flash_message', 'Account not found'); return redirect('account/create'); } $stateModel = new \App\State(); $states_for_dropdown = $stateModel->getStatesForDropdown(); $acctTypes = ['Checking', 'Savings', 'Credit Card']; return view('account.edit')->with('accounts', $accounts)->with(['states_for_dropdown' => $states_for_dropdown])->with(['acctTypes' => $acctTypes]); }
public function getAccount($member_id) { $accounts = Account::where('memberId', '=', $member_id)->get(); $amount = 0; foreach ($accounts as $account) { if ($account->type == 1) { $amount += $account->amount; } else { $amount -= $account->amount; } } return $amount; }
function adminConfirm() { $data = Request::all(); if (Account::where('Email', '=', $data['Email'])->count() >= 1) { $admin = Account::where('Email', '=', $data['Email'])->find(1); if ($admin->Password == $data['Password']) { $sessionData = ['Name' => $admin['Name'], 'Email' => $admin['Email'], 'validSession' => 'yes']; Session::put($sessionData); return '1:success'; } else { return '0:User information is wrong.'; } } else { return '0:User information is wrong'; } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request, Transaction $transactions) { // Setup query $query = $transactions->orderBy('timestamp', 'ASC')->with('category', 'vendor'); $activeFilters = []; // Account filter if ($accountFilter = $request->input('account')) { $query->whereHas('account', function ($q) use($accountFilter) { $q->where('slug', '=', $accountFilter); }); $activeFilters['account'] = ['name' => Account::where('slug', '=', $accountFilter)->first()->name, 'removedUri' => http_build_query($request->except('account'))]; } // Vendor filter if ($vendorFilter = $request->input('vendor')) { $query->whereHas('vendor', function ($q) use($vendorFilter) { $q->where('slug', '=', $vendorFilter); }); $activeFilters['vendor'] = ['name' => Vendor::where('slug', '=', $vendorFilter)->first()->name, 'removedUri' => http_build_query($request->except('vendor'))]; } // Category filter if ($categoryFilter = $request->input('category')) { $query->whereHas('category', function ($q) use($categoryFilter) { $q->where('slug', '=', $categoryFilter); }); $activeFilters['category'] = ['name' => Category::where('slug', '=', $categoryFilter)->first()->name, 'removedUri' => http_build_query($request->except('category'))]; } // Business filter if (($businessFilter = $request->input('business')) === "") { $query->where('business_expense', '=', '1'); $activeFilters['business expense'] = ['name' => '', 'removedUri' => http_build_query($request->except('business'))]; } // Charity filter if (($charityFilter = $request->input('charity')) === "") { $query->where('charitable_deduction', '=', '1'); $activeFilters['charitable deduction'] = ['name' => '', 'removedUri' => http_build_query($request->except('charity'))]; } // Execute query $this->transactions = $query->get(); $this->calculateRowBalances(); $rows = $this->transactions->reverse(); return view('transactions.index', ['rows' => $rows, 'balance' => money_format('%(!i', @$rows[0]->balance), 'filters' => $activeFilters])->withInput($request->all()); }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $login = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first(); $stockTypes = StockType::all(); $limitOrders = LimitOrder::all(); if ($login->mtype == 1) { $stocks = Stock::orderBy('stockTypeId')->get(); if (count($stocks) > 0) { foreach ($stocks as $stock) { $clientStocks = ClientStock::where('stockId', '=', $stock->id)->where('status', '=', 0)->get(); $stock->request = $clientStocks; //$stockProducts = AddProduct::sum('quantity')->where('stockId',$stock->id); $stock->quantity = AddProduct::where('stockId', $stock->id)->sum('quantity'); $data[] = $stock; } } else { $data = $stocks; } $clientStocks = ClientStock::all(); $clientAccounts = Account::all(); } else { $stocks = Stock::orderBy('stockTypeId')->where('stockTypeId', 3)->get(); if (count($stocks) > 0) { foreach ($stocks as $stock) { $stock->quantity = AddProduct::where('stockId', $stock->id)->sum('quantity'); $data[] = $stock; } } else { $data = $stocks; } $clientStocks = ClientStock::where('memberId', $login->member_id)->get(); $clientAccounts = Account::where('memberId', $login->member_id)->get(); } $returnData = array('status' => 'ok', 'stocks' => $data, 'stockTypes' => $stockTypes, 'clientStocks' => $clientStocks, 'limitOrders' => $limitOrders, 'clientAccounts' => $clientAccounts, 'code' => 200); return $returnData; }
public function payFromWallet() { $accountTable = Account::where('user_id', Auth::user()->id)->first(); if ($accountTable->balance < 25) { return redirect()->back()->with('message', 'You have not sufficent balance'); } else { $newBalance = $accountTable->balance - 25; Account::where('user_id', Auth::user()->id)->update(['balance' => $newBalance]); Transaction::insert(['tnx_id' => 'aa_' . rand(1, 99999999), 'amount' => 25, 'sign' => '-', 'purpose' => 10, 'date' => Carbon::now(), 'user_id' => Auth::user()->id]); User::where('id', Auth::user()->id)->update(['status' => 1]); return redirect()->back()->with('message', 'Successfully Activated'); } }
public function run() { $start_date = ''; $end_date = ''; $folderpath = 'database/seeds/seed_files'; $folders = File::directories($folderpath); $latest = '11232015'; foreach ($folders as $value) { $_dir = explode("/", $value); $cnt = count($_dir); $name = $_dir[$cnt - 1]; $latest_date = DateTime::createFromFormat('mdY', $latest); $now = DateTime::createFromFormat('mdY', $name); if ($now > $latest_date) { $latest = $name; } } $file_path = $folderpath . "/" . $latest . "/Store Mapping.xlsx"; echo (string) $file_path, "\n"; // dd($file_path); Model::unguard(); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); DB::table('audit_templates')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->template)) { $template = AuditTemplate::where('template', $row->template)->first(); if (count($template) == 0) { $newtemplate = new AuditTemplate(); $newtemplate->template_code = $row->channel_code; $newtemplate->template = $row->template; $newtemplate->save(); } } }); }); DB::table('grade_matrixs')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->enrollment_type)) { $matrix = GradeMatrix::where('desc', $row->enrollment_type)->first(); if (count($matrix) == 0) { $newmatrix = new GradeMatrix(); $newmatrix->desc = $row->enrollment_type; $newmatrix->save(); } } }); }); DB::table('users')->truncate(); DB::table('role_user')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->fullname)) { $userlist = explode("/", $row->fullname); $emaillist = explode("/", $row->email); // dd($row); for ($i = 0; $i < count($userlist); $i++) { $user = User::where('username', $row->username)->first(); if (count($user) == 0) { if (empty($emaillist[$i])) { $email = strtolower($row->username . "@unilever.com"); } else { $email = strtolower($emaillist[$i]); } $newuser = User::create(array('name' => strtoupper($userlist[$i]), 'email' => $email, 'username' => $row->username, 'password' => Hash::make('password'))); $newuser->roles()->attach(3); } else { // $user->name = strtoupper($row->fullname); // $user->username = $row->username; // $user->email = strtolower($row->email); // $user->update(); // if(!$user->hasRole('field')){ // $user->roles()->attach(3); // } // echo $user->hasRole('field'); } } } }); }); DB::table('accounts')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $account = Account::where('account', $row->account)->first(); if (count($account) == 0) { $newaccount = new Account(); $newaccount->account = $row->account; $newaccount->save(); } } }); }); DB::table('customers')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { // var_dump($row); $account = Account::where('account', $row->account)->first(); if (!empty($account)) { $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first(); if (count($customer) == 0) { $newcustomer = new Customer(); $newcustomer->account_id = $account->id; $newcustomer->customer_code = $row->customer_code; $newcustomer->customer = $row->customer; $newcustomer->save(); } } } }); }); DB::table('areas')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $account = Account::where('account', $row->account)->first(); if (!empty($account)) { $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first(); if (!empty($customer)) { $area = Area::where('customer_id', $customer->id)->where('area', $row->area)->first(); if (count($area) == 0) { $newarea = new Area(); $newarea->customer_id = $customer->id; $newarea->area = $row->area; $newarea->save(); } } } } }); }); DB::table('regions')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $region = Region::where('region_code', $row->region_code)->where('region', $row->region)->first(); if (count($region) == 0) { $newregion = new Region(); $newregion->region_code = $row->region_code; $newregion->region = $row->region; $newregion->save(); } } }); }); DB::table('distributors')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $dis = Distributor::where('distributor_code', $row->distributor_code)->where('distributor', $row->distributor)->first(); if (count($dis) == 0) { $newdis = new Distributor(); $newdis->distributor_code = $row->distributor_code; $newdis->distributor = strtoupper($row->distributor); $newdis->save(); } } }); }); DB::table('stores')->truncate(); DB::table('store_user')->truncate(); Excel::selectSheets('Sheet1')->load($file_path, function ($reader) { $records = $reader->get(); $records->each(function ($row) { if (!is_null($row->account)) { $account = Account::where('account', $row->account)->first(); if (!empty($account)) { $customer = Customer::where('account_id', $account->id)->where('customer_code', $row->customer_code)->where('customer', $row->customer)->first(); if (!empty($customer)) { $region = Region::where('region_code', $row->region_code)->first(); $dis = Distributor::where('distributor_code', $row->distributor_code)->first(); $store = Store::where('account_id', $account->id)->where('customer_id', $customer->id)->where('region_id', $region->id)->where('distributor_id', $dis->id)->where('store_code', $row->store_code)->where('store', $row->store_name)->first(); if (count($store) == 0) { $template = AuditTemplate::where('template', $row->template)->first(); $matrix = GradeMatrix::where('desc', $row->enrollment_type)->first(); $newstore = new Store(); $newstore->account_id = $account->id; $newstore->customer_id = $customer->id; $newstore->region_id = $region->id; $newstore->distributor_id = $dis->id; $newstore->store_code = $row->store_code; $newstore->store = $row->store_name; $newstore->grade_matrix_id = $matrix->id; $newstore->audit_template_id = $template->id; $newstore->save(); $emaillist = explode("/", $row->email); for ($i = 0; $i < count($emaillist); $i++) { if (empty($emaillist[$i])) { $email = strtolower($row->username . "@unilever.com"); } else { $email = strtolower($emaillist[$i]); } $user = User::where('email', $email)->first(); $newstore->users()->attach($user->id); } } else { $emaillist = explode("/", $row->email); for ($i = 0; $i < count($emaillist); $i++) { if (empty($emaillist[$i])) { $email = strtolower($row->username . "@unilever.com"); } else { $email = strtolower($emaillist[$i]); } $user = User::where('email', $email)->first(); $store->users()->attach($user->id); } } } } } }); }); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); Model::reguard(); }
public function checkWtwAmount($wtwAmount) { $balance = Account::where('user_id', Auth::id())->first()->balance; if ($balance < $wtwAmount) { echo json_encode("You do not have sufficient balance"); } }
public function index(Request $request) { $members = Member::where('status', 1)->orWhere('status', 2)->get(); $login = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first(); $server_status = MetaData::select('meta_value')->where('meta_key', 'server_status')->first(); if ($login->mtype == 3 || $login->mtype == 1) { foreach ($members as $member) { $accounts = Account::where('memberId', '=', $member->id)->get(); $amount = 0; foreach ($accounts as $account) { if ($account->type == 1) { $amount += $account->amount; } else { $amount -= $account->amount; } } $clientStocks = ClientStock::where('memberId', $member->id)->where('status', '<', 6)->get(); $pending = 0; if (count($clientStocks) > 0) { foreach ($clientStocks as $clientStock) { if ($clientStock->status == 1) { $pending += $clientStock->margin + $clientStock->commission; } elseif ($clientStock->status == 2 || $clientStock->status == 5) { $pending += $clientStock->margin + $clientStock->commission + $clientStock->holding_cost; } elseif ($clientStock->status == 4 || $clientStock->status == 6) { $pending += $clientStock->margin + $clientStock->commission + $clientStock->holding_cost + $clientStock->delivery_charge; } else { } } } $member->pending = $pending; $member->amount = $amount; $user[] = $member; } } else { //$user = $members; foreach ($members as $member) { if ($member->id == $login->member_id) { $accounts = Account::where('memberId', '=', $member->id)->get(); $amount = 0; foreach ($accounts as $account) { if ($account->type == 1) { $amount += $account->amount; } else { $amount -= $account->amount; } } $clientStocks = ClientStock::where('memberId', $member->id)->where('status', '<', 5)->get(); $pending = 0; if (count($clientStocks) > 0) { foreach ($clientStocks as $clientStock) { if ($clientStock->status == 1) { $pending += $clientStock->margin + $clientStock->commission; } elseif ($clientStock->status == 2 || $clientStock->status == 5) { $pending += $clientStock->margin + $clientStock->commission + $clientStock->holding_cost; } elseif ($clientStock->status == 4 || $clientStock->status == 6) { $pending += $clientStock->margin + $clientStock->commission + $clientStock->holding_cost + $clientStock->delivery_charge; } else { } } } $member->pending = $pending; $member->amount = $amount; } $user[] = $member; } } $returnData = array('status' => 'ok', 'members' => $user, 'user' => $login->member_id, 'server_status' => $server_status['meta_value'], 'code' => 200); return $returnData; }
/** * Update the specified resource in storage. *passing array for function sync * @param int $id * @return Response */ public function update($id, AccountRequest $request) { //email verification - unique $email = $request->input('email'); $accounts = Account::where('email', $email)->get(); $numOfAccount = $accounts->count(); $accountIds = $accounts->lists('id'); if ($numOfAccount == 1 && $accountIds[0] == $id) { $account = Account::findOrFail($id); $account->update($request->all()); //users - accounts Auth::user()->accounts()->sync([$id]); //account - files if ($request->file('file')) { $fileOrgName = $request->file('file')->getClientOriginalName(); $filePath = realpath('fileStorage') . '/' . $id; if (!file_exists($filePath)) { File::makeDirectory($filePath, 0775, true); } $account->files()->create(['file' => $fileOrgName]); $request->file('file')->move($filePath, $fileOrgName); } } else { Session::flash('flash_message', 'Your email already has been taken. Please try another one.'); Session::flash('flash_message_important', true); } return redirect('accounts'); }
public function addBusStop(Request $request, $id) { $input = $request->all(); $agent = Merchant::find($id); if (isset($input['type']) && $input['type'] == 'genticket') { $validator = Validator::make($request->all(), ["terminal_id" => "required", "ticket_type" => "required"]); if ($validator->fails()) { if ($request->ajax()) { return response()->json($validator->messages()); } else { return \Redirect::back()->withErrors($validator)->withInput(); } } //$input = $request->all(); $stack = new Ticketstack(); $stack->batch_code = Ticket::stackCode(); $stack->created_at = date("Y-m-d H:i:s"); $stack->save(); $ticket = new Ticket(); $terminal = Busstop::where("id", "=", trim($input['terminal_id']))->first(); $count = $input['qty']; $account = Account::where("app_id", "=", $input['app_id'])->first(); for ($k = 1; $k <= $count; $k++) { $time = time(); DB::table('ticketseed')->insert(['code' => $time]); $mid = DB::table("ticketseed")->max("id"); //$amount = ($input['ticket_type'] == 1) ? $terminal->one_way_to_fare : $terminal->one_way_from_fare ; $amount = 1000; Ticket::insert(array("code" => $ticket->ticketCode($mid), "account_id" => $account->id, "app_id" => $input['app_id'], "agent_id" => $id, "serial_no" => $ticket->uniqueID($mid), "terminal_id" => $terminal->id, "stack_id" => $stack->id, "route_id" => $input['route_id'], "amount" => $amount, "ticket_type" => $input['ticket_type'])); } $account->balance += $amount * $input['qty']; $agent->balance += $amount * $input['qty']; $account->update(); $agent->update(); } else { $account = new Account(); $mid = Account::uniqueID() + 1; $terminal_id = DB::table("busstops")->where("short_name", "=", $input['short_name'])->pluck("id"); $account->merchant_id = $input['merchant_id']; $account->busstop_id = $terminal_id; $m = $account->merchant_id + $mid; $realid = uniqid($m); $realid = substr($realid, -1, 5); $realid = $realid . str_pad($mid, 5, 0, STR_PAD_LEFT); $account->account_id = uniqid($m); if ($account->save()) { return response()->json("record saved successfully"); } } }
<thead> <tr> <th>ID</th> <th>Station </th> <th>Balance</th> <th>GeoData</th> <th>Distance</th> <th colspan="3">Action</th> </tr> </thead> <tbody id="tblCompany"> <?php if ($mybusstops) { foreach ($mybusstops as $busstop) { echo "\n <tr>\n <td>{$busstop->id}</td>\n <td>{$busstop->name}</td>"; $balance = \App\Account::where("app_id", $busstop->app_id)->pluck("balance"); echo "<td>{$balance}</td>\n <td>{$busstop->geodata}</td>\n <td>{$busstop->distance}</td>\n <td><button class='edtBusstopLink btn-primary' cname='{$busstop->name}' croute_id='{$busstop->route_id}' cid='{$busstop->id}' cdesc='{$busstop->description}' cgeodata='{$busstop->geodata}' cdistance='{$busstop->distance}' ><span class='glyphicon glyphicon-pencil'></span></button></td>\n <td><button class='genTicket btn-primary' cname='{$busstop->name}' appid='{$busstop->app_id}' routeid='{$busstop->route_id}' stationid='{$busstop->station_id}'><span class='fa fa-ticket'></span></button></td>\n <td><button class='delLink btn-danger' dname='{$busstop->name}' url='/busesstop/busstopdelete/{$busstop->id}' data-target='#myDelete' data-toggle='modal'><span class='glyphicon glyphicon-trash'></span></button></td>\n </tr>\n "; } } else { echo "<tr><td colspan='8'>No Record Found</td> </tr>"; } ?> </tbody> <tfoot> <tr> <th>ID</th> <th>Station </th> <th>Balance</th> <th>GeoData</th> <th>Distance</th> <th colspan="3">Action</th>
public function __construct(Account $account) { $this->account = $account->where('company_id', Auth::user()->company_id)->where('account_year_id', session('account')); }
protected function info($username) { $info = Account::where('username', '=', $username)->orderBy('id', 'desc')->select('code', 'time')->get(); return $info; }
public function ccPostIndex($id) { $user = Auth::user(); $cc = Account::where('id', $id)->where('userID', $user->id)->first(); $cc->name = Input::get('name'); $cc->creditLimit = Input::get('limit'); $cc->statementDay = Input::get('date'); $cc->save(); return redirect('home')->with('message', 'Credit Card information updated successfully.'); }
public function postPassword($gameId) { $rule = ['username' => 'required']; $validator = Validator::make(Input::all(), $rule); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $account = Account::where('username', '=', Input::get('username'))->where('game_id', '=', $gameId)->where('user_id', '=', Auth::user()->id)->first(); if (!$account) { return Redirect::back()->withErrors(['username' => 'User name is not exist'])->withInput(); } if (Gate::denies('update', $account)) { return "Hey guy, Don't try to hack, This account is not belong to you."; } $password = Str::random(16); $account->password = $password; $account->save(); $user = Auth::user(); Mail::send('emails.forgetAccountPassword', ['user' => $user, 'account' => $account, 'password' => $password], function ($m) use($user) { $m->from('*****@*****.**', 'CS4VN'); $m->to($user->email, $user->name)->subject('Mật Khẩu CS4VN'); }); return Redirect::back(); }
/** * 根据tag获取公众号. * * @param string $tag tag * * @return Model */ public function getByTag($tag) { return $this->model->where('tag', $tag)->first(); }
/** * rtrBalanceTransfer function * Deduct from users roi balance of Account table * Insert deduct transaction on transaction table, Add amount to receiver roi balance again insert adding transaction * @return string */ public function wtwBalanceTransfer($wtwAmount, $receiverName) { // return $wtwAmount; // return $receiverName; if ($wtwAmount) { $balanceRecord = Account::where('user_id', Auth::id())->first(); $receiverInfo = User::where('username', $receiverName)->first(); // for getting receiver id if ($wtwAmount < $balanceRecord->balance) { $newBalanceAfterDeduct = $balanceRecord->balance - $wtwAmount; Account::where('user_id', Auth::id())->update(['balance' => $newBalanceAfterDeduct]); $tnx_id = 'w2w_' . rand(1, 99999999); Transaction::insert(['tnx_id' => $tnx_id, 'amount' => $wtwAmount, 'sign' => '-', 'purpose' => 5, 'date' => Carbon::now(), 'user_id' => Auth::id(), 'related_id' => $receiverInfo->id]); $receiverAccount = Account::where('user_id', $receiverInfo->id)->first(); $preBalance = $receiverAccount->balance; $newBalanceAfterRoiAdded = $preBalance + $wtwAmount; Account::where('user_id', $receiverInfo->id)->update(['balance' => $newBalanceAfterRoiAdded]); Transaction::insert(['tnx_id' => 'w2w_' . rand(1, 99999999), 'amount' => $wtwAmount, 'sign' => '+', 'purpose' => 5, 'date' => Carbon::now(), 'user_id' => Auth::id(), 'related_id' => $receiverInfo->id]); // Sending Email to both with success message and information // return redirect()->back()->with('message','Successfully Balance Transferd'); $tnx = Crypt::encrypt($tnx_id); return redirect()->route('user.transfer.confirm', $tnx); } else { return redirect()->back()->with('message', 'You do not have sufficient balance'); } } else { return redirect()->back()->with('message', 'Request could not processd'); } }
public function editInputManual($id) { if (Gate::denies('account.saldo.update')) { return view(config('app.template') . '.error.403'); } $accountSaldo = AccountSaldo::find($id); if (!$accountSaldo) { abort(404); } $data = ['accounts' => Account::where('data_state', 'input')->lists('nama_akun', 'id'), 'accountSaldo' => $accountSaldo]; return view(config('app.template') . '.account.saldo.update', $data); }
/** * makeDeposit * Data insert into deposit, transaction and roirecords table * Upade carries table * * @return string */ public function makeDeposit(Request $request) { // return $request->pmethod; $depositAmount = $request->deposit; if ($depositAmount) { if ($request->pmethod == 'pm') { return "Processing with Perfect Money"; } else { $account = Account::where('user_id', Auth::user()->id)->first(); if ($account->balance < $depositAmount) { return redirect()->back()->with('message', 'You do not have sufficient balance'); } else { Deposit::insert(['user_id' => Auth::user()->id, 'amount' => $depositAmount, 'pmnt_method' => $request->pmethod, 'pmnt_account' => 'Wallet Balance', 'rcvd_date' => Carbon::now()]); // return "Successfully deposited"; $newDepBalance = $account->balance - $depositAmount; Account::where('user_id', Auth::user()->id)->update(['balance' => $newDepBalance]); // return "Successfully updated"; Transaction::insert(['tnx_id' => 'nd_' . rand(1, 99999999), 'amount' => $depositAmount, 'sign' => '-', 'purpose' => 11, 'date' => Carbon::now(), 'user_id' => Auth::user()->id]); // return "Successfully transaction inserted"; // Create ROI (Return of Income) Schedule $depositTableRow = Deposit::where('user_id', Auth::user()->id)->first(); $roiAmount = $depositAmount * 20 / 100; for ($i = 1; $i <= 10; $i++) { Roirecord::insert(['deposit_id' => $depositTableRow->id, 'amount' => $roiAmount, 'pmnt_date' => Carbon::now()->addMonths($i), 'terms' => $i, 'status' => 0]); } // end for loop // Create ROI (Return of Income) Schedule End // Add Referrar's Comission $referrarId = Auth::user()->referrar_id; $comissionAmount = 10 * $depositAmount / 100; $referrarBalance = Account::where('user_id', $referrarId)->first()->balance; $newRefBalance = $referrarBalance + $comissionAmount; Account::where('user_id', $referrarId)->update(['balance' => $newRefBalance]); // Add Referrar's Comission End //Insert Transaction Table Start Transaction::insert(['tnx_id' => 'drc_' . rand(1, 99999999), 'amount' => $comissionAmount, 'sign' => '+', 'purpose' => 12, 'date' => Carbon::now(), 'user_id' => $referrarId, 'related_id' => Auth::user()->id]); //Insert Transaction Table End $this->carry(Auth::user()->id, Auth::user()->upline_id, $depositAmount); $this->updateMatchingQualify(); return redirect()->back()->with('message', "Successfully Deposited"); } } } else { return redirect()->back()->with('message', 'Request could not processd'); } }
/** * Display a listing of the resource. * * @return Response */ public function searchLeadList() { $term = Input::get('q'); $leads = Account::where('first_name', 'like', '%' . $term . '%')->orWhere('last_name', 'like', '%' . $term . '%')->latest()->get(); return $leads; }
protected function portalEmailBalance($id) { if ( \Auth::user() ) { $userTypeID = \Auth::user()->userTypeId; if ( $userTypeID == 1 || $userTypeID == 2 ) { $authUserId = \Auth::id(); $authEmployee = Employee::where('userId','=',$authUserId)->first(); $accountId = $id; $account = Account::where('id','=',$accountId)->first(); $contact = Contact::where('accountId','=',$accountId)->where('contactTypeId','=',1)->first(); $balance = Balance::where('accountId','=',$accountId)->first()->balance; $data = array( 'contact' => $contact->firstName . ' ' . $contact->lastName, 'id' => $accountId, 'name' => $account->companyName, 'balance' => $balance, ); $test = "hello"; Mail::send('email_invoice_balance', $data, function ($message) use($contact){ $message->from('*****@*****.**', 'D.C.I. Printing & Graphics, Inc.'); $message->to($contact->email, $contact->firstName)->subject('Account Balance'); }); return Redirect::to('/portal-invoices'); } else { return Redirect::to('/account'); } } else { return Redirect::to('/'); } }
/** * Returns Account info with roles->permissions and activiteSettings * @param Request $request * @object Answer * @return {status_code, result:{BIG JSON} */ public function info(Request $request) { $account = Account::where('id', $this->accountId)->with('roles.permissions', 'activitySettings.pitches')->with(['activitySettings.elevationItems' => function ($query) { $query->where('type', 'elevation'); }])->with(['activitySettings.salesItems' => function ($query) { $query->where('type', 'sales'); }])->with(['activitySettings.leadDataItems' => function ($query) { $query->where('type', 'lead_data'); }])->with(['teams' => function ($query) { $query->withTrashed(); }])->get(); return $account; }
/** * Obtain the user information from provider ex:Facebook. * * @return Response */ public function handleProviderCallback($provider, Request $request) { Log::info("[App\\UserAuthController]: Handle new social user"); // try to find the account who wants to login or register $social_user = Socialite::driver($provider)->user(); $social_account = Account::where('provider', $provider)->where('provider_id', $social_user->id)->first(); $social_avatar = str_replace('normal', 'large', $social_user->avatar); // if the account exists, either answer with a redirect or return the access token // this decision is made when we are checking if the request is an AJAX request Log::info($provider); Log::info($social_avatar); if ($social_account) { $user = $social_account->user; $this->handleAvatar($user, $social_avatar); Log::info("[App\\UserAuthController]: Login event fired"); event(new UserLoginEvent($user)); if (!$request->ajax()) { return redirect(env('FRONTED_URL') . '/#/register?token=' . $this->auth->fromUser($user), 302); } return response($this->auth->fromUser($user), 200); } // there is the use case where user exist but wants to login using social account. // similar to the previous use case, account fo AJAX request if ($social_user) { $user_exists = User::where('email', $social_user->user['email'])->first(); $this->handleAvatar($user, $social_avatar); if ($user_exists) { if (isset($provider) && isset($social_user->id) && isset($social_user->token)) { $user_exists->accounts()->save(new Account(['provider' => $provider, 'provider_id' => $social_user->id, 'access_token' => $social_user->token])); } Log::info("[App\\UserAuthController]: Login event fired"); event(new UserLoginEvent($user_exists)); if (!$request->ajax()) { return redirect(env('FRONTED_URL') . '/#/register?token=' . $this->auth->fromUser($user_exists), 302); } return response($this->auth->fromUser($user_exists), 200); } } Log::info("[App\\UserAuthController]: No Social Account exists, creation begins"); // the account does not exist yet. // redirect to frontend, if user is coming per link, adding contents for form fields if (!$request->ajax()) { return redirect(env('FRONTED_URL') . '/#/register?first_name=' . $social_user->user['first_name'] . '&last_name=' . $social_user->user['last_name'] . '&email=' . $social_user->user['email'] . '&gender=' . ('male' === $social_user->user['gender'] ? 'm' : 'f') . '&provider=' . $provider . '&provider_id=' . $social_user->id . '&provider_token=' . $social_user->token, 302); } // otherwise return the data as json return response(array('first_name' => $social_user->user['first_name'], 'last_name' => $social_user->user['last_name'], 'email' => $social_user->user['email'], 'gender' => 'male' === $social_user->user['gender'] ? 'm' : 'f', 'provider' => $provider, 'provider_id' => $social_user->id, 'provider_token' => $social_user->token), 200); }