目前,这仅在会话中存储名字。我需要存储位于同一数据库行中的一些其他字段,例如 user_role 和 city。我怎样才能做到这一点 ?
DashboardContaroller.php
public function getIndex( Request $request )
{
$this->data['firstNames'] = \DB::table('tb_users')->orderBy('first_name')->lists('first_name', 'first_name');
Session::put('firstName', $request->get('first_name'));
return view('dashboard.index',$this->data);
}
Run Code Online (Sandbox Code Playgroud)
索引.blade.php
<form action="" method="post">
{!! Form::select('first_name', $firstNames) !!}
<button type="submit" value="Submit">Go</button>
</form>
Run Code Online (Sandbox Code Playgroud)
看法
<p>{{Session::get('firstName','default value')}}</p>
Run Code Online (Sandbox Code Playgroud)
您可以将数据存储为数组:
Session::put('user', ['first_name' => $request->get('first_name'), 'user_role' => Auth::user()->user_role, 'city' => Auth::user()->city]);
Run Code Online (Sandbox Code Playgroud)
看法:
<p>{{Session::get('user')['city']}}</p>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8908 次 |
| 最近记录: |