Beispiel #1
0
 public function index()
 {
     //If the register form was sent
     if (Form::exists('register_form')) {
         //We check if all the input are filled
         if (Form::checkEmpty(array('mainAddress', 'firstName', 'mail', 'name', 'password', 'password_check', 'phoneNumber', 'birthday'))) {
             $error = "Veuillez remplir tous les champs";
             return View::render("register/index.php", array('error' => $error));
         }
         //We check if the mail address is not already taken
         if (Client::getOneBy(array('_mail' => Form::get('mail')))) {
             $error = "Cette adresse e-mail est déjà associée à un compte. Veuillez en choisir une autre.";
             return View::render("register/index.php", array('error' => $error));
         }
         //We check if the password and the check are the same
         if (Form::get('password') != Form::get('password_check')) {
             $error = "Les mots de passe ne correspondent pas.";
             return View::render("register/index.php", array('error' => $error));
         }
         //We create a new User, and associate the values
         $user = new Client();
         $user->setFirstName(Form::get('firstName'));
         $user->setMail(Form::get('mail'));
         $user->setName(Form::get('name'));
         $user->setPassword(Form::get('password'));
         $user->setPhoneNumber(Form::get('phoneNumber'));
         $user->setBirthday(Form::get('birthday'));
         //We save this User in the DB
         $user->save();
         $address = new \App\Model\Address();
         $address->setAddress(Form::get('mainAddress'));
         $address->setUser($user);
         $address->save();
         $user->setAddress($address);
         $user->save();
         return View::render("register/complete.php", array('user' => $user));
     }
     return View::render("register/index.php");
 }
Beispiel #2
0
 /**
  * Seed the Database with Users
  */
 private function addUsers()
 {
     //Add the Entrepreneur if he doesn't exist
     if (!Entrepreneur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Entrepreneur();
         $user->setFirstName("Bill");
         $user->setName("Gates");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
     //Add a Restaurateur if he doesn't exist
     if (!Restaurateur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Restaurateur();
         $user->setFirstName("MacDonald");
         $user->setName("Ronald");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
     //Add a Restaurateur if he doesn't exist
     if (!Restaurateur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Restaurateur();
         $user->setFirstName("Tiki");
         $user->setName("Ming");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
     //Add a Restaurateur if he doesn't exist
     if (!Restaurateur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Restaurateur();
         $user->setFirstName("Jean");
         $user->setName("Bono");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
     //Add a Client if he doesn't exist
     $address = Address::getOneBy(array('address' => '18 Rue des Roses'));
     if (!$address) {
         $address = new Address();
         $address->setAddress('18 Rue des Roses');
         $address->save();
     }
     if (!Client::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Client();
         $user->setFirstName("Jean");
         $user->setName("Bon");
         $user->setMail("*****@*****.**");
         $user->setAddress($address);
         $user->setBirthday("10 Janvier 1973");
         $user->setPhoneNumber("593 489 2354");
         $user->setPassword("123123");
         $user->save();
         $address->setUser($user);
         $address->save();
     }
     //Add a Livreur if he doesn't exist
     if (!Livreur::getOneBy(array('_mail' => "*****@*****.**"))) {
         $user = new Livreur();
         $user->setFirstName("Jiang");
         $user->setName("Li");
         $user->setMail("*****@*****.**");
         $user->setPassword("123123");
         $user->save();
     }
 }