错误:存储数据时“不允许序列化闭包”。我在文本区域上使用 CKEditor。当没有更多文本时,数据会被存储,但当有更多文本(如第一个问题)并且在https://www.lipsum.com上得到回答时 ,则会在保存数据时显示错误。存储功能public function store(Request $request){ $this->validate($request, [ 'noticeTitle' => 'required', 'noticeDesc' => 'required', ]); $notice = new Notice; $notice->noticeTitle = $request->input('noticeTitle'); $notice->noticeDesc = $request->input('noticeDesc'); $notice->batch_id = $request->input('targetedGroup'); if($request->hasFile('add_file')) { $noticeTitle = $request->input('noticeTitle'); $filename = $request->add_file->getClientOriginalName(); $request->add_file->storeAs('public/noticeFile/additionalFiles', $noticeTitle.'_'.$filename); $path = $noticeTitle.'_'.$filename; $notice->file = $path; } dd($notice); try{ $notice->save(); Session::flash('success', 'Notice Saved'); return redirect()->route('notice.index'); } catch (\Throwable $th){ Session::flash('danger', $th); return redirect()->route('notice.index'); }}$notice 变量的转储如下"noticeTitle" => "Lorem Ipsum Notice New" "noticeDesc" => """ <h2>What is Lorem Ipsum?</h2> <p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ▶ """ "batch_id" => "3" "file" => "Lorem Ipsum Notice New_s.pdf" ]
1 回答
HUWWW
TA贡献1874条经验 获得超12个赞
解决了。问题不在于商店功能,而在于迁移。对于 CKEditor 上的数据,我使用的是string
on migration。改了text
之后问题就解决了。
- 1 回答
- 0 关注
- 75 浏览
添加回答
举报
0/150
提交
取消