大家好我想在表格视图中将变量传递给我的post方法
这是我的表单视图更新代码
-clearPersistedState
这是我的控制器
{{
Form::open(array(
'route' => ['faculty/dept2''],
'method' => 'post',
'id' => 'form-getdept-setting'))
}}
{{
Form::label( 'faculty_id', 'Faculty Id:' )
}}
{{
Form::text( 'faculty_id', '', array(
'id' => 'faculty_id',
'placeholder' => 'Enter Faculty Id',
'maxlength' => 20,
'required' => true))
}}
{{
Form::submit( 'Find Information', array(
'id' => 'btn-getdeptsetting'))
}}
{{
Form::close()
}}
这是我的路线
public function getAllDept2()
{
if ( Session::token() !== Input::get( '_token' ) )
{
return Response::json(array(
'msg' => 'Unauthorized attempt to create setting'));
}
$fId = Input::get( 'faculty_id' );
$faculty = Facultyform::where('File_Number', '=', $fId)
->get();
if($faculty[0]['isChair'] == 'Y')
{
$department = $faculty[0]['Home_Department_Desc'];
return $department;
/* $queries = DB::getQueryLog();
$last_query = end($queries);
var_dump($last_query);
die(); */
}
else{
return Redirect::to('/');
}
}
Route::post('faculty/dept/{department}', array(
'as' => 'faculty/dept/{department}',
'uses' => 'FacultyController@getAllDept2'
));
dd($ department)结果显示用户的部门。
答案 0 :(得分:0)
我使用Redirect :: to()将变量传递给其他路径
public function getAllDept2()
{
if ( Session::token() !== Input::get( '_token' ) )
{
return Response::json(array(
'msg' => 'Unauthorized attempt to create setting'));
}
$fId = Input::get( 'faculty_id' );
$faculty = Facultyform::where('File_Number', '=', $fId)
->get();
if($faculty[0]['isChair'] == 'Y')
{
$department = $faculty[0]['Home_Department_Desc'];
return Redirect::to('facutly/dept/'.$department);
/* $queries = DB::getQueryLog();
$last_query = end($queries);
var_dump($last_query);
die(); */
}
else{
return Redirect::to('/');
}
}