コード例 #1
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $month = new Month();
     $month->userID = $user->id;
     $month->cash = 0.0;
     $month->income = 0.0;
     $month->profit = 0.0;
     $month->name = date('M');
     $month->year = date('Y');
     $month->save();
     return $user;
 }
コード例 #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //This creates a new Entry in the Month table and carries over the data from last month.
     $months = DB::select('select * from month where name = :month and year = :year', ['month' => date("M"), 'year' => date("Y")]);
     if ($months) {
     } else {
         $months = DB::select('select * from month');
         foreach ($months as $month) {
             $new = new Month();
             $new->userID = $month->userID;
             $new->cash = $month->cash;
             $new->year = date("Y");
             $new->name = date("M");
             $new->save();
         }
     }
 }