ask("enter account name"); while (true) { $account = $this->ask('enter account number'); if (!CommonService::isMobile($account)) { $this->info("[error] please enter a phone number"); continue; } $is_exist = Admin::where("mobile", $account)->exists(); if (!$is_exist) break; $this->info("[error] account exists"); } while (true) { $password = $this->secret("enter the password"); if (strlen($password) < 6) { $this->info('[error] password`s length less than 6'); continue; } $re_password = $this->secret("enter the password again"); if ($password == $re_password) break; $this->info("[error] password not the same"); } Admin::create([ 'name'=>$name?:"Admin", 'mobile'=>$account, 'password'=>Hash::make($password), 'desc'=>"系统管理员" ]); return Command::SUCCESS; } }