Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在laravel won'中向注册表单添加字段;行不通_Php_Mysql_Laravel_Registration - Fatal编程技术网

Php 在laravel won'中向注册表单添加字段;行不通

Php 在laravel won'中向注册表单添加字段;行不通,php,mysql,laravel,registration,Php,Mysql,Laravel,Registration,我一直在尝试在Laravel的注册表单中添加一些额外的字段,但它不起作用。我没有收到任何错误,页面只是返回给我,没有上传到我的数据库 当我第一次设置Laravel时,这个功能正常工作,但当我尝试添加额外字段时,它就不再工作了。我已经在下面发布了我的代码 RegisterController.php <?php namespace App\Http\Controllers\Auth; use App\User; use App\Http\Controllers\Controlle

我一直在尝试在Laravel的注册表单中添加一些额外的字段,但它不起作用。我没有收到任何错误,页面只是返回给我,没有上传到我的数据库

当我第一次设置Laravel时,这个功能正常工作,但当我尝试添加额外字段时,它就不再工作了。我已经在下面发布了我的代码

RegisterController.php

    <?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'dateofbirth' => 'required|string|max:255',
            'Level' => 'required|string|max:255',
            'password' => 'required|string|min:6|confirmed',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'dateofbirth' => $data['dateofbirth'], 
            'level' => $data['level'],
            'password' => bcrypt($data['password']),
        ]);
    }
}

只是一个提示:您的验证使用的是
级别
而不是
级别
。此外,您将字段添加到此迁移中,而不是创建新迁移。您是否重置了迁移?

doe的验证错误?您是否在模型中设置了受保护的$fillable?不,我没有收到任何错误,我还检查了laravel.log@ab_abyes@mchev:protected$filleble=[“姓名”、“电子邮件”、“出生日期”、“级别”“密码”];验证错误可能没有记录到laravel.log中。在您的视图文件中用
dd($errors->all())
确认。是的,我手动导入了表,因为这对我来说比较容易。我的登记表现在都在用。谢谢
        <?php

    use Illuminate\Support\Facades\Schema;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;

    class CreateUsersTable extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::create('users', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name');
                $table->string('email')->unique();
                $table->string('dateofbirth');
                $table->string('level');            
                $table->string('password');
                $table->rememberToken();
                $table->timestamps();
            });
        }

        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::dropIfExists('users');
        }
    }
             <div class="panel-body">
                        <form class="form-horizontal" method="POST" action="{{ route('register') }}">
                            {{ csrf_field() }}

                            <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                                <label for="name" class="col-md-4 control-label">Name</label>

                                <div class="col-md-6">
                                    <input id="name" type="text" class="form-control" name="name" value="{{ old('name') }}" required autofocus>

                                    @if ($errors->has('name'))
                                        <span class="help-block">
                                            <strong>{{ $errors->first('name') }}</strong>
                                        </span>
                                    @endif
                                </div>
                            </div>

                            <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                                <label for="email" class="col-md-4 control-label">E-Mail Address</label>

                                <div class="col-md-6">
                                    <input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required>

                                    @if ($errors->has('email'))
                                        <span class="help-block">
                                            <strong>{{ $errors->first('email') }}</strong>
                                        </span>
                                    @endif
                                </div>
                            </div>

                              <div class="form-group{{ $errors->has('dateofbirth') ? ' has-error' : '' }}">
                                <label for="dateofbirth" class="col-md-4 control-label">D.O.B</label>

                                <div class="col-md-6">
                                    <input id="dateofbirth" type="dateofbirth" class="form-control" name="dateofbirth" value="{{ old('datebirth') }}" required>

                                    @if ($errors->has('dateofbirth'))
                                        <span class="help-block">
                                            <strong>{{ $errors->first('dateofbirth') }}</strong>
                                        </span>
                                    @endif
                                </div>
                            </div>

                              <div class="form-group{{ $errors->has('level') ? ' has-error' : '' }}">
                                <label for="level" class="col-md-4 control-label">Level</label>

                                <div class="col-md-6">
                                    <input id="level" type="level" class="form-control" name="level" value="{{ old('email') }}" required>

                                    @if ($errors->has('level'))
                                        <span class="help-block">
                                            <strong>{{ $errors->first('level') }}</strong>
                                        </span>
                                    @endif
                                </div>
                            </div>

                            <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                                <label for="password" class="col-md-4 control-label">Password</label>

                                <div class="col-md-6">
                                    <input id="password" type="password" class="form-control" name="password" required>

                                    @if ($errors->has('password'))
                                        <span class="help-block">
                                            <strong>{{ $errors->first('password') }}</strong>
                                        </span>
                                    @endif
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="password-confirm" class="col-md-4 control-label">Confirm Password</label>

                                <div class="col-md-6">
                                    <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-md-6 col-md-offset-4">
                                    <button type="submit" class="btn btn-primary">
                                        Register
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>