2015-10-15 60 views
0

我决定在预定义的用户表laravel 5选择输入未在用户表中插入

Schema::create('users', function(Blueprint $table) 
     { 
      $table->increments('id'); 
      $table->string('name'); 
      $table->string('email')->unique(); 
      $table->string('password', 60); 
      $table->string('type', 50); 
      $table->rememberToken(); 
      $table->timestamps(); 
     }); 

添加型柱和我已经将其设置为可填充,以便它可以被填充。

protected $fillable = ['name', 'email', 'password', 'type']; 

我也在我的注册视图中所做的选择输入取值

<div class="form-group"> 
    <label class="col-md-4 control-label">User Type</label> 
    <div class="col-md-6"> 
    <select class="form-control" name="type" id="type"> 
     <option value="0">Patient</option> 
     <option value="1">Doctor</option> 
     <option value="2">Nurse</option> 
    </select> 
    </div> 
</div> 

但只有空值添加到我的类型的列,你觉得有什么问题吗?

回答

0

您需要删除value属性或将其设置为期望值'患者'。

<div class="form-group"> 
    <label class="col-md-4 control-label">User Type</label> 
    <div class="col-md-6"> 
    <select class="form-control" name="type" id="type"> 
     <option>Patient</option> 
     <option>Doctor</option> 
     <option>Nurse</option> 
    </select> 
    </div> 
</div> 
+0

我做了两......还是一无所获:(这个工作对我来说最后一次..但现在它只是发送空白 –

+0

在你的控制器试试'DD($请求 - >所有());'之前保存并查看内容。还可以发布控制器代码。 – whoacowboy