比较来自世界各地的卖家的域名和 IT 服务价格

LARAVALT临时数据存储

我正在尝试暂时存储数据并在其他一些页面上打印它们。 只要我没有更新页面,所选数据只能活下来。 我怎么能修复它 ? 谢。

index.blade.php


<form action="" method="post">
{!! Form::select/'first_name', $firstNames/ !!}
<button type="submit" value="Submit">Go</button>
</form>


DashboardController.php


public function getIndex/ Request $request /
{

$this->data['online_users'] = \DB::table/'tb_users'/->orderBy/'last_activity','desc'/->limit/10/->get//;
$this->data['firstNames'] = \DB::table/'tb_users'/->orderBy/'first_name'/->lists/'first_name', 'id'/;
$request->session//->put/'first_name', input::get/'first_name'//;
$this->data['active'] = '';
return view/'dashboard.index',$this->data/;

}


回声


<p>{{Session::get/'first_name'/}}</p>
已邀请:

小明明

赞同来自:

使用会话变量保存不同页面上的数据。

页 1


{{Session::put/'firstName','John'/}}


页 2


{{Session::get/'firstName'/}}


所以试试


public function getIndex/ Request $request /
{

$this->data['online_users'] = \DB::table/'tb_users'/->orderBy/'last_activity','desc'/->limit/10/->get//;
$this->data['firstNames'] = \DB::table/'tb_users'/->orderBy/'first_name'/->lists/'first_name', 'id'/;
\Session::put/'first_name', $request->get/'first_name'//;
$this->data['active'] = '';
return view/'dashboard.index',$this->data/;

}


将路由添加到Web中间软件以进行会话使用!

Routes.php


Route::group/['middleware' =>['web']],function//{

Route::get/'myroute','DashboardController@getIndex'/;

}/;


阅读更多 laravel 会话阅读
https://laravel.com/docs/5.3/session

卫东

赞同来自:

商店商店 :-
会议 /['first_name' => $request->get/'first_name'/]/

获得会话值 :-
会议 /'first_name'/

冰洋

赞同来自:

尝试更换
compact/'data'/


$data

郭文康

赞同来自:

试着这样做


public function getIndex/ Request $request /
{
$data['online_users'] = \DB::table/'tb_users'/->orderBy/'last_activity','desc'/->limit/10/->get//;
$data['firstNames'] = \DB::table/'tb_users'/->orderBy/'first_name'/->lists/'first_name', 'id'/;
$data['first_name'] = input::get/'first_name'/;
$data['active'] = '';
return view/'dashboard.index'/->with/'data', $data/;
}


像这样站起来


<p>{{ $data['first_name'] }}</p>

要回复问题请先登录注册