示例#1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = User::create(['email' => '*****@*****.**', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]);
     User::create(['email' => '*****@*****.**', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]);
     $admin = Role::where('name', 'owner')->first();
     $user->attachRole($admin);
     // create asset accounts for user #1.
     TestData::createAssetAccounts($user);
     // create bills for user #1
     TestData::createBills($user);
     // create some budgets for user #1
     $this->createBudgets($user);
     // create some categories for user #1
     $this->createCategories($user);
     // create some piggy banks for user #1
     TestData::createPiggybanks($user);
     // create some expense accounts for user #1
     $this->createExpenseAccounts($user);
     // create some revenue accounts for user #1
     $this->createRevenueAccounts($user);
     // create journal + attachment:
     $this->createAttachments($user);
     // create opening balance for savings account:
     $this->openingBalanceSavings($user);
 }
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function run()
 {
     $this->createUsers();
     // create accounts:
     TestData::createAssetAccounts($this->user);
     $this->createExpenseAccounts();
     $this->createRevenueAccounts();
     TestData::createBills($this->user);
     TestData::createPiggybanks($this->user);
     $this->createRules();
     // preference to only see account #1 on frontpage.
     $this->createPreferences();
     // dates:
     $start = Carbon::now()->subYears(2)->startOfMonth();
     $end = Carbon::now()->endOfDay();
     $current = clone $start;
     while ($current < $end) {
         $month = $current->format('F Y');
         // create salaries:
         $this->createIncome('Salary ' . $month, $current, rand(2000, 2100));
         // pay bills:
         $this->createRent('Rent for ' . $month, $current, 800);
         $this->createWater('Water bill for ' . $month, $current, 15);
         $this->createTV('TV bill for ' . $month, $current, 60);
         $this->createPower('Power bill for ' . $month, $current, 120);
         // pay daily groceries:
         $this->createGroceries($current);
         // create tag (each type of tag, for date):
         $this->createTags($current);
         // go out for drinks:
         $this->createDrinksAndOthers($current);
         // save money every month:
         $this->createSavings($current);
         // buy gas for the car every month:
         $this->createCar($current);
         // budget limit for this month, on "Groceries".
         $this->createBudgetLimit($current, 'Groceries', 400);
         $this->createBudgetLimit($current, 'Bills', 1000);
         $this->createBudgetLimit($current, 'Car', 100);
         echo 'Created test data for ' . $month . "\n";
         $current->addMonth();
     }
 }