我可以';s访问我在laravel 4中发布的从控制器查看的变量


i can's access to the variable i posted to view from controller in laravel 4

我有laravel应用程序。我将控制器中的变量$res发布到我的视图中,在视图中我无法访问我发布的变量。这是我的代码:

我的路线:

Route::get('/pickUpQuestion','createQuizController@showResult');

我的控制器:

public function showResult()
{
    $prio = Input::get('quiz_prio');
    $cat = Input::get('quiz_cat');
    $les = Input::get('quiz_less');
    $rdate = Input::get('date_start');
    $res = DB::select("select title from quiz where categories_id='$r2' and lesson_id='$r3' and priority_id='$r1' and date_start='$rdate'");
    return View::make('pickUpQuestion')->with('result',$res);
}

以及我的观点:

@extends('layouts.master')
@section('content')
<?php
   var_dump($res);
?>
@stop

我使用post方法将查询中的值从不同视图中的另一个表单获取到此视图

错误在于函数with()

第一个参数需要是将在视图中使用的变量的名称,第二个参数是第一个参数的值。

代码应该看起来像这个

return View::make('pickUpQuestion')->with('res',$res);