Ejemplo n.º 1
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), User::$rules);
     if ($validator->passes()) {
         //$validator true, save ke db
         $user = new User();
         $user->username = Input::get('username');
         $user->email = Input::get('email');
         $user->password = Hash::make(Input::get('password'));
         $user->admin = false;
         if ($user->save()) {
             //kalau save sukses maka bikin profile
             ProfileController::save($user->id);
         } else {
             return Redirect::to('/register')->with('message', 'save gagal');
         }
         return Redirect::to('/')->with('message', 'makasih udah register');
     } else {
         //validator false, kirim notifikasi
         return Redirect::to('/register')->with('message', 'Hal Berikut Error')->withErrors($validator)->withInput;
     }
 }