Trying to Save Comments but the application redirects me to an empty page

I’ve made a blog and now I’m trying to implement a comment section. I want it so that when the user tries to post, it’s saves the comment and redirects the user to the same page. But when I write a comment and try to post it, the application redirects me to a different page. I’m learning how to make a blog with laravel, so I don’t know when to use url and when to use routes. Here’s the code that I’ve written.

<div class="card ml-5 col-lg-8">
<ul class="list-group list-group-horizontal">
<h5 class="list-group-item active">
<div class="card-body">
<form method="post" action="">
<textarea name="comment" class="form-control py-5"></textarea>
<input type="submit" class="btn btn-primary mt-3">

<div class="card ml-5 col-lg-8">
<h5 class="card-header mb-4">Comments<span class="badge badge-info ml-2"> </span></h5>
<div class="card-body mt-3">
@foreach($blog->comments as $comment)
<blockquote class="blockquote">
<p class="mb-0"></p>
<footer class="blockquote-footer">Username</footer>

function save_comment(Request $request,$slug,$id)
$data = new Comment;
return back();

Route::get('/blog/', [AppHttpControllersBlogController::class, 'index'])->name('blog');
Route::get('blogs/{slug}','[email protected]')->name('');
Route::get('blog.update/{id}','[email protected]');
Route::put('blog.update/{id}','[email protected]');
Route::post('save_comment/{slug}/{id}','[email protected]_comment')->name('save_comment');
Route::get('/admin/blog', '[email protected]')->name('');

If there’s someone willing to assist come up with a solution to this problem, please assist me. I think the problem lies where I’ve written the url lies. When I change the url to route, it gives me an error of route not defined. Route::resource(‘/blog’,’AppHttpControllersBlogController’);

from Newest questions tagged laravel-5 – Stack Overflow

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.