我正在尝试在React中创建简单的upvote系统,但是我收到奇怪的错误消息,即使我在db中定义了投票,并且投票当前为0,投票还是为零。问题出在 class AddSlugToPosts extends Migration
{
public function up()
{
Schema::table('posts', function ($table) {
$table->string('slug')->unique()->after('body')->default();
});
}
public function down()
{
Schema::table('posts', function ($table) {
$table->dropColumn('slug');
});
}
}
public function rules()
{
return [
'title' => 'required|max:255',
'body' => 'required',
'slug' => 'required|alpha_dash|min:5|max:255|unique:posts,slug'
];
}
public function store(PostRequest $request)
{
$post = Post::create($request->all());
Session::flash('success', 'The blog post was successfully saved!');
return redirect()->route('posts.show', $post->id);
}
中功能,并且我得到正确的ID。
有人可以解释为什么我遇到此错误吗?
UpvotePost