【发布时间】:2020-04-05 09:03:00
【问题描述】:
这是我得到的错误
SQLSTATE[HY000]:一般错误:1 表帖子没有名为标题的列(SQL:插入“posts”(“caption”、“image”、“user_id”、“updated_at”、“created_at”)值(标题,
为什么会这样
张贴表代码
Schema::create('posts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id');
$table->string('caption');
$table->string('image');
$table->timestamps();
$table->index('user_id');
blade.php 代码
<input id="caption"
type="text"
class="form-control @error('caption') is-invalid @enderror"
name="caption"
value="{{ old('caption') }}"
autocomplete="caption" autofocus>
我有我的 PostsController.php
public function store()
{
$data = request()->validate([
'caption' => 'required',
'image' => ['required', 'image'],
]);
auth()->user()->posts()->create($data);
dd(request()->all());
}
为什么会出现错误?
【问题讨论】: