您好我正在使用laravel php而我在我发送它的页面中没有得到我输入的值 当我在我的控制器功能上dd($ numexam)它告诉我它是空的。 我是laravel和php以及编程的初学者
public function updatenote(Request $request){
$num=$request->input('numexam');
dd($num);
$exam = Exam::find($num);
$note=$request->input('note');
$exam->note=$note;
$exam->save();
return Redirect::back();
}
这是我的路线web.php
Route::get('/ajout', 'ExamsController@create');
Route::post('/ajout', 'ExamsController@store')->name('exam.import');
Route::get('/notemodifier', 'ExamsController@updatenote');
<!-- Button trigger modal -->
<td>
<button value="{{$verification->numexam}}"
onClick="document.getElementById('numexam').innerHTML=this.value"
type="button" class="btn btn-light" data-toggle="modal" data-
target="#exampleModalCenter">
Update mark
</button>
</td>
我的观点要素:
<form action="/notemodifier" method="get">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modifier la note</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<center>
<label>Taper la nouvelle note:</label>
<input required type="text" name="note">
</center>
<input type="hidden" name="numexam" id="numexam">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
<button type="submit" class="btn btn-primary">Modifier</button>
</div>
</div>
</form>
</div>
</div>
答案 0 :(得分:0)
Route::get('/notemodifier', 'ExamsController@updatenote');
将其更改为
Route::post('/notemodifier', 'ExamsController@updatenote');
控制器中的
public function updatenote(Request $request){
$input = $request->all();
dd($input);
$exam = Exam::find($input['numexam']);
$note=$input('note');
$exam->note=$note;
$exam->save();
return Redirect::back();
}