2015-01-05 1 views
0

내가 생각한 것보다 더 간단한 방법이 있어야한다는 것을 알고 있으므로 여기서 물어볼 것입니다.블레이드에서 루트로 변수를 전달하고 그곳에서 다른 경로로 패스

나는

public function create() { 

    return View::make('exam.index'); 
} 
ExamController을 (당신이 시작 테스트를 클릭하면) 여기에서 $exam->id을 통과

@foreach($category->exams as $exam) 
    <tr> 
     <td>{{$exam->id}}</td> 
     <td>{{$exam->title}}</td> 
     <td>od {{$exam->start_date}} do {{$exam->end_date}}</td> 
     <td class="center"><span class="badge">{{$exam->number_of_points}}</span></td> 
     <td class="center"><a href="#"><i class="fa fa-arrow-circle-right"></i> Start test</a></td> 
    </tr> 
@endforeach() 

이이 경로를 사용하고 그 변수

Route::get('exam','[email protected]'); // this is where i dont know how to set route to pass to another one 

을 통과해야합니다

그리고 finnaly 사용자가 submit을 클릭하면, 그 $ exam_id를 ajax에 보냄으로써 난 그냥 내가 그걸 통과 할 방법을 알고하지 않는 양식에 대신 1 $exam_id처럼 무작위 시험 ID 번호를 넣을 때 t 시험

{{ Form::open(['data-remote', 'method' => 'GET', 'route' => ['exam_data',$exam_id]]) }} 
    <div class="exam-name"> 
    </div> 

    <div class="form-group exam"> 
     Click Start to start the test! 
    </div> 

    <div class="form-group"> 

     {{ Form::submit('Start', ['class' => 'btn btn-default','id'=>'btn-next-question', 'data-confirm']) }} 

    </div> 

{{Form::close()}} 

국도 버튼을

Route::get('exam/{id}',['as' => 'exam_data', 'uses' => '[email protected]']); 

모든 제출을 위해 잘 작동합니다. 어떤 도움을 주셔서 감사합니다.

+0

세션 내에 정보를 저장하십시오. 그런 다음 모든 요청에 ​​대해 사용할 수 있습니다. –

+0

좋은 아이디어, 시도해 보겠습니다. – MePo

답변

0

나는 변화 시작 테스트 컨트롤러

같은
public function create() 
{ 

    $exam_id = Input::get('id'); 
    return View::make('exam.index', array('exam_id' => $exam_id)); 
} 

보이는 경로

<td class="center"><a href="{{ URL::route('exam_id', array('id'=>$exam->id)) }}"><i class="fa fa-arrow-circle-right"></i> Start Test</a></td> 

시험 경로

Route::get('exam',['as' => 'exam_id', 'uses' => '[email protected]']); 

에 배열을 전달하는 것이 었습니다 처음 내가 무슨 짓을 파악 나머지 코드는 같습니다.