如何以以下格式重定向 URL:
我的代码:
return Redirect::to('home/viewcustomer/$cusid')
->with('status','success')
->with('message','success');
例:
home/viewcustomer/8
在字符串引号中使用变量时,您需要注意字符串引号。只需更新您的代码
Redirect::to('home/viewcustomer/$cusid')
到
Redirect::to("home/viewcustomer/$cusid")
^^ ^^
好吧,
我通常使用
会话和重定向,因此您必须在控制器中定义它
Use Session;
Use Redirect;
然后
public function example(){
Session::flash('status','Your message');
return Redirect::to('/yourRoute');
}
如果你想在你的视图中显示你的消息,你必须这样做......
@if(Session::has('status'))
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<p><strong>Success!!</strong> </p>
<ul>
<li>{{ Session::get('status') }}</li>
</ul>
</div>
@endif
希望这有帮助!!
Ps:对不起英语不好:)