【发布时间】:2018-12-16 18:46:55
【问题描述】:
目前正在使用 laravel 5.6 并且无法更新我创建的表单。
完整的错误是:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null (SQL: update `companies` set `name` = , `description` = this is a SE company., `updated_at` = 2018-12-16 10:05:55 where `id` = 1)
edit.blade.php 文件如下:
<form method="post" action="{{route('companies.update',[$company->id]) }}">
{{ csrf_field() }}
<input type="hidden" name="_method" value="put">
<div class="form-group">
<label for="company-name">Name<span class="required">*</span></label>
<input placeholder="Enter name"
id="company-name"
required
name="description"
spellcheck="false"
class="form-control"
value="{{ $company->name }}"
/>
</div>
<div class="form-group">
<label for="company-content">Description</label>
<textarea placeholder="Enter description"
style="resize:vertical"
name="description"
id="company-content"
rows="5" cols="5"
spellcheck="false"
class="form-control autosize-target text-left">
{{ $company->description}}
</textarea>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary"
value="Submit"/>
</div>
</form>
这是迁移文件:
public function up()
{
Schema::create('companies', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->longText('description')->nullable();
$table->integer('user_id')->unsigned();
$table->timestamps();
});
}
任何关于我做错了什么的指导将不胜感激。
【问题讨论】:
-
您能否在您的 PHP 中显示您正在处理此表单的部分?这可能是部分原因。
标签: php mysql laravel-5.6