Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用laravel中的数据从控制器重定向到命名路由_Laravel - Fatal编程技术网

使用laravel中的数据从控制器重定向到命名路由

使用laravel中的数据从控制器重定向到命名路由,laravel,Laravel,我要试着解释我的问题: 我有一个名为“form.index”的命名路由,其中显示了一个html表单 在FormController中,我检索所有表单数据 在对这些数据做了一些处理之后,我想重定向到另一个命名路由“form.matches”,其中包含一些项集合 URL form.index->website示例/表单 form.matches->website示例/匹配 FormController public function match(FormularioRequest $reques

我要试着解释我的问题:

  • 我有一个名为“form.index”的命名路由,其中显示了一个html表单
  • 在FormController中,我检索所有表单数据
  • 在对这些数据做了一些处理之后,我想重定向到另一个命名路由“form.matches”,其中包含一些项集合
URL

form.index->website示例/表单

form.matches->website示例/匹配

FormController

public function match(FormularioRequest $request)
{
    // Some stuffs

    $list = /*Collection*/;

    return redirect()->route('form.matches')->with(compact('list'));
}

public function matches()
{
    // How to retrieve $list var here?
    return view('form.views.matches')->with(compact('list'));
}
问题:


当重定向match函数时,matches函数中出现错误“Undefined variable:list”。

您可以使用Redirect::route()重定向到命名路由,并将参数数组作为第二个参数传递

Redirect::route('route.name',array('param1' => $param1,'param2' => $param2));

希望这对您有所帮助。

您可以使用Redirect::route()重定向到命名路由,并将参数数组作为第二个参数传递

Redirect::route('route.name',array('param1' => $param1,'param2' => $param2));
 public function match(Request $request)
 {
// Operations

$list = //Data Collection;

return redirect()->route('form.matches')->with('list',$list);
}

In view
@if(Session::has('list'))
<div>  
{!!Session::get('list')!!}
</div>
@endif
希望这对您有所帮助。

公共函数匹配(Request$Request)
 public function match(Request $request)
 {
// Operations

$list = //Data Collection;

return redirect()->route('form.matches')->with('list',$list);
}

In view
@if(Session::has('list'))
<div>  
{!!Session::get('list')!!}
</div>
@endif
{ //操作 $list=//数据收集; return redirect()->route('form.matches')->with('list',$list); } 鉴于 @if(会话::has('list')) {!!Session::get('list')!!} @恩迪夫
公共功能匹配(请求$Request)
{
//操作
$list=//数据收集;
return redirect()->route('form.matches')->with('list',$list);
}
鉴于
@if(会话::has('list'))
{!!Session::get('list')!!}
@恩迪夫

公共函数匹配($list)
?解决方案已经可用,我想您可以检查@Ashish的可能重复项。我已经尝试过该解决方案,但它对我不起作用。@Alvaro\u请尝试为其使用会话。
公共函数匹配($list)
?解决方案已经可用。我想您可以检查@Ashish的可能重复项。我已经尝试过该解决方案,但对我无效。@Alvaro\u请尝试使用session。然后如何在matches()函数中获取集合?然后如何在matches()函数中获取集合?