Пример #1
0
 /**
  * Run the database seeds.
  * Crea 5 usuarios y por cada uno crea 2 categorias y 3 cuentas.
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; $i++) {
         $user = User::create(array('email' => $faker->unique()->email, 'password' => '123456', 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'birthdate' => $faker->dateTimeBetween($startDate = '-24 years', $endDate = '-18 years')->format('Y-m-d')));
         //categories
         for ($j = 0; $j < 2; $j++) {
             Category::create(array('name' => $faker->word, 'description' => $faker->text(100), 'user_id' => $user->id));
         }
         //accounts
         Account::create(array('name' => 'Cash', 'starting_balance' => $faker->randomFloat(2), 'current_balance' => $faker->randomFloat(2), 'notes' => $faker->text(100), 'user_id' => $user->id));
         Account::create(array('name' => 'Debit Card', 'starting_balance' => $faker->randomFloat(2), 'current_balance' => $faker->randomFloat(2), 'notes' => $faker->text(100), 'user_id' => $user->id));
         Account::create(array('name' => 'Credit Card', 'starting_balance' => $faker->randomFloat(2), 'current_balance' => $faker->randomFloat(2), 'notes' => $faker->text(100), 'user_id' => $user->id));
     }
 }
Пример #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['first_name' => $data['first_name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
Пример #3
0
 /**
  * @param CreateUserRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CreateUserRequest $request)
 {
     User::create($request->all());
     return redirect()->route('admin.users.index');
 }