Beispiel #1
0
 public function signup()
 {
     // grappping the registered user information via request
     $name = Request::getParam('name');
     $email = Request::getParam('email');
     $pass = Request::getParam('pass');
     $mobile = Request::getParam('mobile');
     $tel = Request::getParam('tel');
     $address = Request::getParam('address');
     $diagnostic = Request::getParam('diagnostic');
     $description = Request::getParam('description');
     $hash = UserModel::getHash();
     $user_columns = ['name' => $name, 'email' => $email, 'pass' => Hash::make($pass), 'mobile' => $mobile, 'tel' => $tel, 'address' => $address, 'hash' => $hash, 'avatar' => ''];
     // inserting new user
     if (UserModel::insert($user_columns)) {
         // check if there is a complain then insert it
         $complain = ['user_id' => UserModel::lastId(), 'diagnostic' => $diagnostic, 'description' => $description];
         if (!empty($description) && !empty($diagnostic)) {
             ComplainModel::insert($complain);
         }
         // inserting permissions for the user as normal
         $permissions = ['user_id' => UserModel::lastId()];
         PermissionModel::insert($permissions);
         // login the user
         $u = new User($hash);
         $u->login();
         // redirect the user to profile page
         redirect(route('user.profile'));
     } else {
         Response::error(401);
     }
 }