我正在博客站点上工作,因此我尝试使用Summer note文本编辑器插入文本。我面临的问题是,在提交了详细的文本后,Laravel抛出了一个错误,那就是-
我的控制器代码
$data = [
'user_id' => Auth::id(),
'blog_title' => $request->title,
'blog_slug' => $slug,
'category_id' => $category,
'blog_summery' => $request->summary,
'blog_details' => $request->summernote,
'thumbnail' => $file
];
try {
Blog::create($data);
//store image into storage directory
Storage::putFileAs('public/blogs', $image, $file);
$notification = [
'message' => 'nothing went wrong',
'alert-type' => 'success'
];
return redirect()->back()->with($notification);
} catch (\Throwable $th) {
$notification = [
// 'message' => 'oops! Something went wrong',
'message' => $th->getMessage(),
'alert-type' => 'warning'
];
return redirect()->back()->with($notification);
}
博客表迁移
public function up()
{
Schema::create('blogs', function (Blueprint $table) {
$table->id();
$table->integer('user_id');
$table->string('blog_title', 100);
$table->string('blog_slug', 100);
$table->unsignedBigInteger('category_id')->nullable();
$table->foreign('category_id')
->references('id')
->on('categories')
->onDelete('set null')
->onUpdate('cascade');
$table->string('blog_summery');
$table->text('blog_details');
$table->string('thumbnail', 100);
$table->timestamps();
});
}