我仍然是一名学生,而且仍然是这些框架的新手
所以我的路线中有两个控制器:
Route::resource('homeworks', 'HomeworkController');
Route::resource('submithomeworks', 'SubmithomeworkController');
在views / Homework / show.blade.php中,我有:
href="{{ URL::action('submithomeworks.create', $homeworks->id) }}"
所以网址将来自
http://localhost:8000/homeworks/1
到
http://localhost:8000/submithomeworks/create?1
那么有什么方法可以将$homework->id
在这种情况下只存储1
到submithomeworks
表吗?
我在SubmithomeworksController
public function store()
{
$rules = array(
'homework_id' => 'required',
'homework_body' => 'required'
);
$submithomework = new Submithomework;
$submithomework->homework_id = Input::get('homework_id');
$submithomework->homework_body = Input::get('homework_body');
$submithomework->student_id = Auth::user()->id;
$submithomework->save();
Session::flash('message', 'Homework successfully added.');
return Redirect::to('homeworks');
}
但是在视图中我该怎么做?它不会存储homework_id
表示它仍为NULL