I'm trying to save variables from my view to controller and then save it in databases but im getting MethodNotAllowedHttpException.
Here are my view
<form method="POST" action="">
<div class="form-group">
<label name="nim"><h3>NIM :</h3></label>
<select name ="mahasiswasn" class="selectpicker" data-live-search="true" data-width="500px" title="Choose the Student Number">
@foreach($nim as $nm)
<option value=""></option>
@endforeach
</select>
</div>
<div class="form-group">
<label name="matkul"><h3> MK :</h3></label>
<select name ="matkulsn" class="selectpicker" data-live-search="true" data-width="500px" title="Choose the subject">
@foreach($matkul as $mkl)
<option value=""></option>
@endforeach
</select>
</div>
<div class="form-group">
<label name="hari">Hari :</label>
<input id="hari" name="hari" class="form-control">
</div>
<div class="form-group">
<label name="status">Status :</label>
<input id="status" name="status" class="form-control">
</div>
<input type="submit" value="Add Absensi " class="btn btn-success btn-lg btn-block">
<input type="hidden" name="_token" value="">
</form>
My Controller (AbsensiController)
public function store(Request $request)
{
$this->validate($request,array(
'nim' =>'required',
'matkul' =>'required',
'hari' =>'required',
'status' =>'required'
));
//store in database
$post = new PostAbsensi;
$post->nim = $request->get('mahasiswasn');
$post->mk = $request->get('matkulsn');
$post->hari = $request->get('hari');
$post->status = $request->get('status');
$post->save();
Session::flash('success','data successfully saved!');
return redirect()->route('absensi.show', $post->id);
}
My Routes :
Route::resource('absensi','AbsensiController');
Please Help, thank you for your attention.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire