我在我的本地主机中访问它。这样的注册表格:https : //postimg.org/image/5gswtx4gn/
我想添加一些文本字段和组合框。例如,级别,级别,用户名等
当我访问代码时,我很困惑。代码是这样的:
控制器寄存器是这样的:
<?php namespace App\Http\Controllers\Auth; use App\User; use Validator; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\RegistersUsers; class RegisterController extends Controller { use RegistersUsers; protected $redirectTo = '/home'; public function __construct() { $this->middleware('guest'); } protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:6|confirmed', ]); } protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); } }
它是供应商中的load registeruser。就像这样 :
<?php namespace Illuminate\Foundation\Auth; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Auth\Events\Registered; trait RegistersUsers { use RedirectsUsers; public function showRegistrationForm() { return view('auth.register'); } public function register(Request $request) { $this->validator($request->all())->validate(); event(new Registered($user = $this->create($request->all()))); $this->guard()->login($user); return $this->registered($request, $user) ?: redirect($this->redirectPath()); } protected function guard() { return Auth::guard(); } protected function registered(Request $request, $user) { // } }
注册视图是这样的:
<div class="register-box-body"> <p class="login-box-msg">Register a new membership</p> <form method="post" action="{{ url('/register') }}"> {!! csrf_field() !!} <div class="form-group has-feedback{{ $errors->has('name') ? ' has-error' : '' }}"> <input type="text" class="form-control" name="name" value="{{ old('name') }}" placeholder="Full Name"> <span class="glyphicon glyphicon-user form-control-feedback"></span> @if ($errors->has('name')) <span class="help-block"> <strong>{{ $errors->first('name') }}</strong> </span> @endif </div> <div class="form-group has-feedback{{ $errors->has('email') ? ' has-error' : '' }}"> <input type="email" class="form-control" name="email" value="{{ old('email') }}" placeholder="Email"> <span class="glyphicon glyphicon-envelope form-control-feedback"></span> @if ($errors->has('email')) <span class="help-block"> <strong>{{ $errors->first('email') }}</strong> </span> @endif </div> <div class="form-group has-feedback{{ $errors->has('password') ? ' has-error' : '' }}"> <input type="password" class="form-control" name="password" placeholder="Password"> <span class="glyphicon glyphicon-lock form-control-feedback"></span> @if ($errors->has('password')) <span class="help-block"> <strong>{{ $errors->first('password') }}</strong> </span> @endif </div> <div class="form-group has-feedback{{ $errors->has('password_confirmation') ? ' has-error' : '' }}"> <input type="password" name="password_confirmation" class="form-control" placeholder="Confirm password"> <span class="glyphicon glyphicon-lock form-control-feedback"></span> @if ($errors->has('password_confirmation')) <span class="help-block"> <strong>{{ $errors->first('password_confirmation') }}</strong> </span> @endif </div> <div class="row"> <div class="col-xs-8"> <div class="checkbox icheck"> <label> <input type="checkbox"> I agree to the <a href="#">terms</a> </label> </div> </div> <!-- /.col --> <div class="col-xs-4"> <button type="submit" class="btn btn-primary btn-block btn-flat">Register</button> </div> <!-- /.col --> </div> </form> <a href="{{ url('/login') }}" class="text-center">I already have a membership</a> </div>
我想问一下,如何在表格上添加文本字段和组合框进行注册?我很困惑。因为从供应商(Illuminate \ Foundation \ Auth \ RegistersUsers)调用了注册视图
如果您由于使用的是官方laravel auth而想要在注册过程中添加一些自定义字段,则可以在以下位置添加字段: /resources/views/auth/register.blade.php
/resources/views/auth/register.blade.php
然后您可以验证输入内容并将其保存在: /app/Http/Controllers/Auth/RegisterController.php
/app/Http/Controllers/Auth/RegisterController.php
您不需要向供应商中的registeruser添加任何内容,因为在每次安装或更新作曲家之后,添加的所有内容都会更改和替换。