Can someone please help me fix this issue? When i click submit it doesnt work! I think the problem lies in the action="" of the form. Is the route correct? If it is why it is not working?
These are my routes:
Route::middleware(['auth'])->group(function () {
Route::get('/', 'HomeController@index')->name('home');
Route::resource('stocks', 'StockController');
Route::get('/stocks/{stock_tag}/doctor','DoctorController@index')->name('stock.doctor');
Route::get('/stocks/{stock_tag}/doctor/create','DoctorController@create')->name('stock.doctor.create');
Route::post('/stocks/{stock_tag}/doctor/store','DoctorController@store')->name('stock.doctor.store');
});
My store function in DoctorController
public function store(Request $request,$stock_tag)
{
//
$stock = Stock::find($stock_tag);
if(Auth::check()){
$doctor = Doctor::create([
'date_of_visit' => $request->input('date_of_visit'),
'doc_name' => $request->input('doc_name'),
'remarks' => $request->input('remarks'),
'description' => $request->input('description'),
'tag' => $stock->tag_no
]);
if($doctor){
return redirect()->route('stocks.doctor.index', ['doctor'=> $doctor->tag])
->with('success' , 'Visit created successfully');
}
}
return back()->withInput()->with('errors', 'Error creating new Visit');
}
This is my view:
<form method="post" action="" enctype="multipart/form-data">
<div class="form-inline">
<label for="date">Date of Visit</label>
<input type="date" name="date_of_visit" max="2030-12-31">
</div>
<div class="form-inline">
<label for="doc_name">Doctor Name: </label>
<input type="text" name="doc_name">
</div>
<div class="form-inline">
<label for="remarks">Remarks </label>
<input type="text" name="remarks">
</div>
<div class="form-inline">
<label for="description">Medication and Execution </label>
<input type="text" name="description">
</div>
</form>
<div class="form-group">
<input type="submit" class="btn btn-primary"
value="Submit"/>
</div>
</div>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire