/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(AccountRequest $request) { $account = new Account(['glosa' => $request['glosa'], 'montoDebe' => $request['sumDebe'], 'montoHaber' => $request['sumHaber'], 'transaction_id' => $request['nume']]); $account->save(); Session::flash('message', 'Comprobante creado'); return redirect()->route('newAccount'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @param Account $account * @return \Illuminate\Http\Response */ public function store(Request $request, Account $account) { $this->validate($request, ['name' => 'required|unique:accounts', 'slug' => 'required|unique:accounts']); $input = $request->except(['_token']); $account->fill($input)->save(); return redirect('accounts')->with('success', $account->name . ' account successfully added.'); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $this->validate($request, ['account' => 'required|unique:accounts|max:100']); $account = new Account(); $account->account = $request->account; $account->save(); Session::flash('flash_message', 'Account successfully added!'); return redirect()->route("account.index"); }
/** * @return bool */ public function process() { while ($line = fgetcsv($this->csv, 1000, ';')) { $transaction = Transaction::firstOrNew(['statement' => $line[2], 'amount' => $this->doConvertion($line[3]), 'balance' => $this->doConvertion($line[4]), 'executed' => Carbon::createFromFormat('d-m-Y', $line[0]), 'rate' => Carbon::createFromFormat('d-m-Y', $line[1])]); if (!$this->account->addTransaction($transaction)) { return false; } } return true; }
/** * Attach an existing user to an account * @param Account $account Account * @param User $user User * @return \Illuminate\Http\RedirectResponse */ public function postAttachExistingUser(Account $account, User $user) { if ($user->id != $account->owner()->first()->id && $account->guests()->where('user_id', $user->id)->count() === 0) { $account->users()->attach($user->id); Mail::send('emails.inviteExistingUser', ['account' => $account], function (Message $m) use($user) { $m->to($user->email); $m->subject(trans('invitation.inviteExistingUser.emailSubject', ['user' => Auth::user()])); }); } return redirect()->action('Account\\ConfigurationController@getUsers', [$account]); }
public function getSwap($account) { $ac = \App\Account::findOrFail($account); $this->currentUser->agent_account_id = $ac->id; $this->currentUser->save(); return redirect()->back()->with('message', 'Changed Account!'); }
public static function bootTenantableTrait() { static::addGlobalScope(new TenantScope()); static::creating(function (Model $model) { $model->account_id = Account::getCurrent()->id; }); }
public function stores() { $accounts = Account::all(); $data = array(); foreach ($accounts as $account) { $customers = Customer::where('account_id', $account->id)->get(); $account_children = array(); foreach ($customers as $customer) { $areas = Area::where('customer_id', $customer->id)->get(); $customer_children = array(); foreach ($areas as $area) { $regions = Region::where('area_id', $area->id)->get(); $area_children = array(); foreach ($regions as $region) { $distributors = Distributor::where('region_id', $region->id)->get(); $region_children = array(); foreach ($distributors as $distributor) { $stores = Store::where('distributor_id', $distributor->id)->get(); $distributor_children = array(); foreach ($stores as $store) { $distributor_children[] = array('title' => $store->store, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id . "." . $store->id); } $region_children[] = array('select' => true, 'title' => $distributor->distributor, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id . "." . $distributor->id, 'children' => $distributor_children); } $area_children[] = array('select' => true, 'title' => $region->region, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id . "." . $region->id, 'children' => $region_children); } $customer_children[] = array('select' => true, 'title' => $area->area, 'isFolder' => true, 'key' => $account->id . "." . $customer->id . "." . $area->id, 'children' => $area_children); } $account_children[] = array('select' => true, 'title' => $customer->customer, 'isFolder' => true, 'key' => $account->id . "." . $customer->id, 'children' => $customer_children); } $data[] = array('title' => $account->account, 'isFolder' => true, 'key' => $account->id, 'children' => $account_children); } return response()->json($data); }
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 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 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]); }
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { $today = Carbon::today(); $tomorrow = Carbon::tomorrow(); $tomorrowbookinguser = Booking::where('bookingdate', '=', $tomorrow)->get(); $dt = Carbon::now(); $year = $dt->year; $month = $dt->month; $currentmonthbreakfast = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('breakfast', '=', 'on')->count(); $currentmonthlunch = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('lunch', '=', 'on')->count(); $currentmonthdinner = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('dinner', '=', 'on')->count(); $totalbooking = $currentmonthbreakfast + $currentmonthlunch + $currentmonthdinner; $price = Account::whereMonth('accountdate', '=', date('m'))->where('user_id', Auth::user()->id)->sum('amount'); $todaydayshop = Shop::where('shopdate', $today)->get(); $tomorrowshop = Shop::where('shopdate', $tomorrow)->get(); $bookings = Booking::where('bookingdate', '=', $today)->get(); $breakfast = Booking::where('bookingdate', '=', $today)->where('breakfast', '=', 'on')->count(); $lunch = Booking::where('bookingdate', '=', $today)->where('lunch', '=', 'on')->count(); $dinner = Booking::where('bookingdate', '=', $today)->where('dinner', '=', 'on')->count(); $t_breakfast = Booking::where('bookingdate', '=', $tomorrow)->where('breakfast', '=', 'on')->count(); $t_lunch = Booking::where('bookingdate', '=', $tomorrow)->where('lunch', '=', 'on')->count(); $t_dinner = Booking::where('bookingdate', '=', $tomorrow)->where('dinner', '=', 'on')->count(); $useraccounts = DB::table('useraccounts')->where('user_id', Auth::user()->id)->select('user_id', DB::raw("SUM(foodamount) AS t_foodamount"), DB::raw("SUM(houserent) AS t_houserent"), DB::raw("SUM(internetbill) AS t_internetbill"), DB::raw("SUM(utlitybill) AS t_utlitybill"), DB::raw("SUM(buabill) AS t_buabill"), DB::raw("SUM(pay) AS t_pay"))->get(); foreach ($useraccounts as $account) { $amount = $account->t_foodamount + $account->t_houserent + $account->t_internetbill + $account->t_utlitybill + $account->t_buabill; $balance = $amount - $account->t_pay; } return view('home', ['bookings' => $bookings, 'breakfast' => $breakfast, 'lunch' => $lunch, 'dinner' => $dinner, 't_breakfast' => $t_breakfast, 't_lunch' => $t_lunch, 't_dinner' => $t_dinner, 'tomorrow' => $tomorrow, 'todaydayshop' => $todaydayshop, 'tomorrowshop' => $tomorrowshop, 'tomorrowbookinguser' => $tomorrowbookinguser, 'balance' => $balance, 'currentmonthbreakfast' => $currentmonthbreakfast, 'currentmonthlunch' => $currentmonthlunch, 'currentmonthdinner' => $currentmonthdinner, 'totalbooking' => $totalbooking, 'price' => $price]); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $acc = Account::find($id); $ledgers = Ledger::where('account_id', $acc->id)->get(); //dd($ledgers); return view('regular.show', compact('ledgers'), compact('acc')); }
/** * Add new account * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse */ public function postAdd(Request $request) { $this->validate($request, ['name' => 'required|string', 'balance' => 'required|numeric']); $account = Account::create($request->only(['name'])); Auth::user()->accounts()->save($account, ['owner' => 1]); $account->revenues()->create(['amount' => $request->get('balance')]); return redirect()->action('AccountController@getIndex', [$account])->withSuccess(trans('account.add.successMessage', ['account' => $account])); }
public function index() { $days = 31; //# of days compared $accstbp = Account::whereRaw('datediff(accounts.dueDate,curdate()) <= ' . $days . ' and datediff(accounts.dueDate,curdate()) >= 0')->orderByRaw('datediff(accounts.dueDate,curdate()) ASC')->get(); $accspd = Account::whereRaw('datediff(accounts.dueDate,curdate()) < 0')->orderByRaw('datediff(accounts.dueDate,curdate()) ASC')->get(); return view('admin.home', ['accstbp' => $accstbp, 'accspd' => $accspd]); }
public function run() { DB::table('accounts')->delete(); Account::create(['name' => 'Bank', 'number' => 1100, 'type' => 'debit']); Account::create(['name' => 'Post', 'number' => 1200, 'type' => 'debit']); Account::create(['name' => 'Kasse', 'number' => 1000, 'type' => 'debit']); Account::create(['name' => 'Eigenkapital', 'number' => 9000, 'type' => 'credit']); Account::create(['name' => 'Personal', 'number' => 3000, 'type' => 'expense']); }
public function apply(Builder $builder, Model $model) { $account = Account::getCurrent(); if (isset($account)) { $builder->whereHas('account', function ($query) use($account) { $query->where('accounts.id', $account->id); }); } }
public function handle($user) { if ($user->agent_account_id == null) { $account = Account::create(['name' => $user->name, 'type' => 'personal']); $user->agentAccount()->associate($account); $user->personalAccount()->associate($account); $user->accounts()->save($account); $user->save(); } }
/** * Run the database seeds. * * @return void */ public function run() { //$Yodlee = new Yodlee(); //$transactions = $Yodlee->get_account_transactions(); $transactions = json_decode(File::get(storage_path() . "/transactions.json")); $account = Account::create(['accountName' => 'TD GREEN VISA', 'accountHolder' => 'TRISTAN GEMUS', 'runningBalance' => '256.33', 'type' => 1]); foreach ($transactions as $transaction) { $account->transactions()->create(['transactionId' => isset($transaction->viewKey->transactionId) ? $transaction->viewKey->transactionId : null, 'localizedTransactionBaseType' => isset($transaction->localizedTransactionBaseType) ? $transaction->localizedTransactionBaseType : null, 'cardAccountId' => isset($transaction->account->itemAccountId) ? $transaction->account->itemAccountId : null, 'postdate' => isset($transaction->postDate) ? $transaction->postDate : null, 'description' => isset($transaction->description->description) ? $transaction->description->description : null, 'categorizationKeyword' => isset($transaction->categorizationKeyword) ? $transaction->categorizationKeyword : null, 'amount' => isset($transaction->amount->amount) ? $transaction->amount->amount : null, 'keyword_id' => $this->get_keyword_id(isset($transaction->categorizationKeyword) ? $transaction->categorizationKeyword : null)]); } }
public function api(Request $request) { $Yodlee = new Yodlee(); $transactions = $Yodlee->get_account_transactions(); $account = Account::create(['accountName' => 'TD GREEN VISA', 'accountHolder' => 'TRISTAN GEMUS', 'runningBalance' => '256.33']); foreach ($transactions as $transaction) { // return print_r($transaction, true); $account->transactions()->create(['transactionId' => isset($transaction->viewKey->transactionId) ? $transaction->viewKey->transactionId : null, 'localizedTransactionBaseType' => isset($transaction->localizedTransactionBaseType) ? $transaction->localizedTransactionBaseType : null, 'cardAccountId' => isset($transaction->account->itemAccountId) ? $transaction->account->itemAccountId : null, 'postdate' => isset($transaction->postDate) ? $transaction->postDate : null, 'description' => isset($transaction->description->description) ? $transaction->description->description : null, 'categorizationKeyword' => isset($transaction->categorizationKeyword) ? $transaction->categorizationKeyword : null, 'amount' => isset($transaction->amount->amount) ? $transaction->amount->amount : null, 'keyword_id' => $this->get_keyword_id(isset($transaction->categorizationKeyword) ? $transaction->categorizationKeyword : null)]); } return print_r($account->transactions, true); }
/** * * Description: Save Transaction * Component: AddTransactionFormModal * */ public function saveTransaction(SaveTransactionPostRequest $request) { $account = Account::find($request->input('id')); $transactionType = TransactionType::where('code', $request->input('transactionType'))->first(); if ($transactionType->account_type === 'DR') { $this->validate($request, ['amount' => 'max:' . $account->balance]); } $transaction = Transaction::create(['transactionDate' => Carbon::parse($request->input('transactionDate'))->toDateString(), 'amount' => $request->input('amount'), 'transaction_type_id' => $transactionType->id, 'account_id' => $request->input('id'), 'notes' => $request->input('notes') === '' ? null : $request->input('notes')]); $account->balance = $this->recomputeRunningBalance($account->id); $account->save(); return response()->json(['message' => 'New Transaction Posted.']); }
public function index() { $userCount = User::count(); $accountCount = Account::count(); $now = time(); // or your date as well $startDay = '2016-02-05'; $your_date = strtotime($startDay); $datediff = $now - $your_date; $runDay = floor($datediff / (60 * 60 * 24)); return view('admin.index', ['userCount' => $userCount, 'accountCount' => $accountCount, 'startDay' => $startDay, 'runDay' => $runDay]); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $this->validate($request, ['account_name' => 'required|max:255']); $input = $request->all(); $input['branch_id'] = Auth::user()->branch_id; $input['company_id'] = Auth::user()->company_id; $input['user_id'] = Auth::user()->id; $input['account_year_id'] = session('account'); Account::create($input); flash()->success('Account Created Successfully !'); return redirect('account'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(LoanApprovalRequest $request) { $appli = LoanApplication::findOrFail($request->id); //$appli->accepted = $request::get('accept'); //$appli->save(); //if($appli->accepted=='true'){ if ($request->accept == 'true') { $acc = new Account(); $acc->loan_id = $appli->loan_id; $acc->member_id = $appli->member_id; $acc->terms = $appli->terms; $acc->amountGranted = $appli->amountGranted; $acc->comaker = $appli->comaker; $acc->dateGranted = $request->date; $acc->dueDate = $acc->dateGranted; $acc->dueDate->addDays($acc->terms); $acc->balance = $acc->amountGranted; $acc->save(); $ledger = new Ledger(); $ledger->account_id = $acc->id; $ledger->curDate = $acc->dateGranted; $ledger->particulars = $request->particular; $ledger->reference = $request->reference; $ledger->avaiment = $acc->amountGranted; $ledger->amountPayed = 0; $ledger->interestDue = 0.0; $ledger->penaltyDue = 0.0; $ledger->principal = 0.0; $ledger->interestPayed = 0.0; $ledger->penaltyPayed = 0.0; $ledger->balance = $acc->amountGranted; $acc->balance = $acc->amountGranted; //toodo $ledger->save(); } $appli->delete(); flash()->success("Success!"); return redirect('/admin'); }
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; }
public function retrieve() { $status = FALSE; DB::connection()->enableQueryLog(); try { $data['users'] = App\Account::all(); $status = TRUE; } catch (Exception $e) { Log::info($e->getMessage()); } Log::info(json_encode(DB::getQueryLog())); $data['status'] = $status; return $data; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request, $id) { try { $account = Account::findOrFail($id); } catch (ModelNotFoundException $e) { return redirect('account')->withErrors("Account with id " . $id . " not found"); } $input = $request::all(); $account->fill($input); try { $account->saveOrFail(); } catch (ValidationException $e) { return redirect('account/edit/' . $id)->withErrors($e->getErrors())->withInput(); } return view('account.show')->with(['account' => $account, 'success' => 'Account ' . $account . ' successfully updated!']); }
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'; } }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $newUser = User::create(['username' => $data['username'], 'password' => bcrypt($data['password']), 'created_at' => gmdate('Y-m-d H:i:s'), 'updated_at' => gmdate('Y-m-d H:i:s'), 'userTypeId' => $data['userTypeId']]); $userTypeId = $newUser->userTypeId; if ($userTypeId == 1 || $userTypeId == 2) { $newEmployee = Employee::create(['userId' => $newUser->id, 'firstName' => $data['firstName'], 'lastName' => $data['lastName'], 'email' => $data['email'], 'phone' => $data['phone'], 'streetAddress' => $data['streetAddress'], 'city' => $data['city'], 'state' => $data['state'], 'zipcode' => $data['zipcode'], 'ssn' => $data['ssn'], 'hourlyRate' => $data['hourlyRate'], 'primaryStoreId' => $data['primaryStoreId']]); } if ($userTypeId == 3) { if (array_key_exists('accountId', $data)) { $newContact = Contact::create(['userId' => $newUser->id, 'accountId' => $data['accountId'], 'firstName' => $data['firstName'], 'lastName' => $data['lastName'], 'email' => $data['email'], 'phone' => $data['phone'], 'contactTypeId' => $data['contactTypeId']]); } else { $newAccount = Account::create(['companyName' => $data['companyName'], 'streetAddress' => $data['streetAddress'], 'city' => $data['city'], 'state' => $data['state'], 'zipcode' => $data['zipcode'], 'accountStatus' => $data['accountStatus']]); $accntId = $newAccount->id; $newContant = Contact::create(['userId' => $newUser->id, 'accountId' => $accntId, 'firstName' => $data['firstName'], 'lastName' => $data['lastName'], 'email' => $data['email'], 'phone' => $data['phone'], 'contactTypeId' => $data['contactTypeId']]); $newBalance = Balance::create(['accountId' => $accntId, 'balance' => 0.0]); } } return $newUser; }
public function create(array $data) { $account = Account::create(['name' => $data['name'], 'state_id' => $data['state_id'], 'city_id' => $data['city_id'], 'zip' => $data['zip'], 'district' => $data['district'], 'address' => $data['address'], 'email' => $data['email'], 'phone' => $data['phone']]); $account->setCurrent(); $user = User::create(['name' => $data['name'], 'state_id' => $data['state_id'], 'city_id' => $data['city_id'], 'zip' => $data['zip'], 'district' => $data['district'], 'address' => $data['address'], 'phone' => $data['phone'], 'email' => $data['email'], 'password' => $data['password']]); VehicleKind::create(['name' => 'Carro']); VehicleKind::create(['name' => 'Moto']); VehicleKind::create(['name' => 'Caminhão']); VehicleBrand::create(['name' => 'Acura']); VehicleBrand::create(['name' => 'Audi']); VehicleBrand::create(['name' => 'BMW']); VehicleBrand::create(['name' => 'Chevrolet']); VehicleBrand::create(['name' => 'Chrysler']); VehicleBrand::create(['name' => 'Citroen']); VehicleBrand::create(['name' => 'Effa']); VehicleBrand::create(['name' => 'Fiat']); VehicleBrand::create(['name' => 'Ford']); VehicleBrand::create(['name' => 'Geely']); VehicleBrand::create(['name' => 'Honda']); VehicleBrand::create(['name' => 'Hyundai']); VehicleBrand::create(['name' => 'Jac Motors']); VehicleBrand::create(['name' => 'Kia']); VehicleBrand::create(['name' => 'Lexus']); VehicleBrand::create(['name' => 'Mazda']); VehicleBrand::create(['name' => 'Mercedes-Benz']); VehicleBrand::create(['name' => 'Mitsubishi']); VehicleBrand::create(['name' => 'Nissan']); VehicleBrand::create(['name' => 'Opel']); VehicleBrand::create(['name' => 'Peugeot']); VehicleBrand::create(['name' => 'Renault']); VehicleBrand::create(['name' => 'Seat']); VehicleBrand::create(['name' => 'Toyota']); VehicleBrand::create(['name' => 'Volkswagen']); VehicleBrand::create(['name' => 'Volvo']); return $user; }