private function registerUser($data, $role)
 {
     if (isset($data['phone_number'])) {
         $data['phone_number'] = str_replace(' ', '', $data['phone_number']);
     }
     if (isset($data['work_phone'])) {
         $data['work_phone'] = str_replace(' ', '', $data['work_phone']);
     }
     $u = new User();
     $data['role_id'] = $role;
     switch (strtolower($role)) {
         case Config::get('constants.ROLE_SELLER'):
             $a = new Seller();
             break;
         case Config::get('constants.ROLE_BROKER'):
             $a = new Broker();
             break;
         default:
             $a = new Buyer();
             $u->status = 2;
             $data['skip_verification'] = true;
             break;
     }
     if (!isset($data['password']) || $data['password'] == "") {
         $pwd = Str::random(10);
         $data['password'] = $data['password_confirmation'] = $pwd;
     }
     if ($u->validate($data)) {
         if ($a->validate($data)) {
             if (isset($pwd)) {
                 Session::set('validate_password', true);
             }
             $data['password'] = Hash::make($data['password']);
             $u->fill($data);
             $code = Str::random(10);
             $u->verification_code = $code;
             $data['verification_code'] = $code;
             $u->save();
             $data['user_id'] = $u->id;
             $a->fill($data);
             $a->save();
             $email = $u->email;
             if (isset($data['skip_verification'])) {
                 $data['url']['link'] = url('/');
                 $data['url']['name'] = 'Go to CompanyExchange';
                 Mail::queue('emails.templates.welcome', $data, function ($message) use($email) {
                     $message->from('*****@*****.**', 'CompanyExchange');
                     $message->to($email);
                     $message->subject('Welcome to CompanyExchange');
                 });
             } else {
                 Mail::queue('emails.templates.progress', $data, function ($message) use($email) {
                     $message->from('*****@*****.**', 'CompanyExchange');
                     $message->to($email);
                     $message->subject('Welcome to CompanyExchange');
                 });
             }
             Auth::loginUsingId($u->id);
             return true;
         }
         Input::flash();
         return $a->getValidator();
     }
     Input::flash();
     return $u->getValidator();
 }