我有一篇文章,我想保存后,进入下一页id
的文章当前会话notes
。
use Session;
public function store(Request $request)
{
$article = new Article($request->all());
$article->user_id = auth()->user()->id;
$article->title = $request->title;
$article->body = $request->body;
$article->id = $request->session()->get('id');
$article->description = $request->description;
$article->save();
return redirect()->route('notes.index')->with('id', $request->id);
}
在笔记页面中有一个input hidden
用于获取session of article id
。
<input type="hidden" class="form-control" value="{{ Session::get('id') }}" name="id" id="id">