如何在会话中获取ID?

时间:2019-06-14 18:52:28

标签: laravel-5.8

我有一篇文章,我想保存后,进入下一页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">

0 个答案:

没有答案