2015-04-04 40 views
0

我有laravel應用程序。 我在我的控制器中發佈了變量$ res到我的視圖,在視圖中,我無法訪問我發佈的變量。 這裏是我的代碼:我可以訪問變量我張貼從laravel 4控制器查看

我的路線:

Route::get('/pickUpQuestion','[email protected]'); 

我的控制器:

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方法形成該視圖

回答

0

錯誤是與功能with()

第一個參數需要是可變的,將在視圖的使用和所述第二參數的名稱是第一參數的值。

的代碼看起來應該是這樣

return View::make('pickUpQuestion')->with('res',$res); 
相關問題