Exemplo n.º 1
0
 public function postCreate(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'type' => 'required', 'number' => 'required|max:4', 'streetaddress' => 'required', 'city' => 'required', 'state_id' => 'required', 'zip' => 'required', 'phone' => 'required']);
     $accounts = new \App\Account();
     $accounts->name = $request->name;
     $accounts->type = $request->type;
     $accounts->number = $request->number;
     $accounts->streetaddress = $request->streetaddress;
     $accounts->streetaddress2 = $request->streetaddress2;
     $accounts->city = $request->city;
     $accounts->state_id = $request->state_id;
     $accounts->zip = $request->zip;
     $accounts->phone = $request->phone;
     $accounts->website = $request->website;
     $accounts->username = $request->username;
     $accounts->user_id = $request->user_id;
     $accounts->save();
     #        \Session::flash('flash_message','Your address was added.');
     \Session::flash('flash_message', 'Your account was added');
     return redirect('/accounts');
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // get a list of all user account's
     $accounts = App\Account::get();
     // calculate the balance of each account
     foreach ($accounts as $account) {
         $account->balance += App\Account::find($account->id)->transactions->where('type', 'DEPOSIT')->sum('amount');
         $account->balance -= App\Account::find($account->id)->transactions->where('type', 'WITHDRAWAL')->sum('amount');
         $account->balance -= App\Transfer::where('account_from', $account->id)->sum('amount');
         $account->balance += App\Transfer::where('account_to', $account->id)->sum('amount');
         $account->save();
     }
 }
Exemplo n.º 3
0
 /**
  * Create an account of a non native provider
  *
  * @param  App\User
  * @return App\Account
  */
 protected function createNonNativeAccount(App\User $user)
 {
     // Create non native provider
     $provider = App\AuthProvider::create(['name' => 'testing', 'title' => 'Testing provider']);
     // Create account
     $data = ['provider_id' => $provider->getKey(), 'user_id' => $user->getKey(), 'uid' => 666];
     $account = App\Account::create($data);
     // Make sure the account is from a non native provider
     $this->seeInDatabase('accounts', $data)->assertGreaterThan(1, $account->provider_id);
     return $account;
 }