I was trying to implement a very simple destroy method for comments on a form, but I'm missing something I can't seem to put my finger on. Upon trying to run the view page, I get the error:
ErrorException (E_ERROR)
Missing required parameters for [Route: form.comments.destroy]
[URI: form/{form}/comments/{comment}].
(View: C:\distributor\resources\views\form\view.blade.php)
My routes file is set up as shown:
......
Route::resource('forms', 'FormController');
Route::get('/formSearch', ['as' => 'search', 'uses' => 'FormController@formSearch']);
Route::resource('form.comments', 'CommentsController');
The form view file where the comments are displayed (and the method is trying to be called from) is set up as:
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Comments</h4>
</div>
<div class="panel-collapse" id="comments" data-context="5" aria-expanded="false">
<div class="panel-body">
@forelse ($form->comments as $comment)
<div class="form-group">
Comment By: <strong></strong> at <strong></strong>
</div>
<div class="form-group col-md-10">
<div class="form-control" readonly></div>
</div>
<div class="btn-group col-md-2">
<form action="" method="POST">
<button class="btn btn-danger" type="submit" data-confirm="Are you sure you want to delete this comment?" value="delete">
<i class="fa fa-trash"></i> Delete
</button>
</form>
</div>
@empty
<div class="form-group">
<div class="form-control" readonly>No Comments Found</div>
</div>
@endforelse
<div class="form-group">
<label class="control-label">
<a href="#">Back To Top</a>
</label>
</div>
</div>
</div>
</div>
Finally, in the controller the method is set up as:
public function destroy($id){
$comment = Comment::find($id);
$comment->delete();
// Redirect
return redirect()->back()->with('status', 'Comment successfully deleted');
}
Any ideas?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2E1FnPv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire