Answer the question
In order to leave comments, you need to log in
Why doesn't the code in laravel controller work?
The code in the controller does not work. The form is being processed, when the button is pressed, the controller should be triggered, which writes the data to the database. The code inside the controller doesn't work. When you click on the button, the page simply reloads (at least it looks like this), it does not give any errors.
web.php:
Route::post('/post/{id}/submit', [\App\Http\Controllers\PostController::class, 'postCommentSubmit'])->name('postCommentSubmit');
public function postCommentSubmit($id, PostRequest $data) {
//здесь код, который не выполняется, не происходит даже редирект
return redirect()->route('home');
}
<form action="{{ route('postCommentSubmit', $post[0]->id) }}" method="post" enctype="multipart/form-data">
@csrf
<textarea name="comment" id="" cols="30" rows="10" placeholder="Your answer"></textarea>
</div>
<button type="submit" class="btn btn-outline-primary">Submit</button>
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question