Laravel Comment System (ok)
https://www.mywebtuts.com/blog/laravel-8-comment-system-example-tutorial
C:\xampp\htdocs\reset\routes\web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PostController;
use App\Http\Controllers\CommentController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::resource('posts', PostController::class);
Route::post('comments', [CommentController::class, 'store'])->name('comments.store');
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');C:\xampp\htdocs\reset\app\Http\Controllers\PostController.php
C:\xampp\htdocs\reset\app\Http\Controllers\CommentController.php
C:\xampp\htdocs\reset\resources\views\post\index.blade.php
C:\xampp\htdocs\reset\resources\views\post\show.blade.php
C:\xampp\htdocs\reset\resources\views\post\commentsDisplay.blade.php
C:\xampp\htdocs\reset\resources\views\post\create.blade.php
C:\xampp\htdocs\reset\app\Http\Controllers\UserController.php
C:\xampp\htdocs\reset\database\migrations\2022_05_14_221257_create_posts_comments_table.php
C:\xampp\htdocs\reset\app\Models\Post.php
C:\xampp\htdocs\reset\app\Models\Comment.php

Hi Artisan,
In this Article I will share something new about how actually work a comment system with laravel 8. I will create a custom comment system in laravel 8. so how to integrate custom nested comments using relationship in laravel 8.
First of all i will exaplain previous example how to create simple authentication using laravel-ui you will learn this first follow this article laravel-8-authentication-tutorial
So, in this example I will create two tables for one is posts and another is comments using the migration command.
Here,i will give you a simple and easy example how to use implement comment system in laravel 8 in laravel simply follow my all steps.
Step 1 : Install Laravel App
In this step, You can install laravel fresh app. So open the terminal and put the bellow command.
Step 2 : Setup Database Configuration
Step 3 : Create Post and Comment Table
In this third step we have to integrate two tables using create migration for "posts" and "comments" table.
Path : /database/migrations/2021_09_20_130819_create_posts_comments_table.php
Now we need to run migration be bellow command:
Step 4 : Create Auth using scaffold
Now, in this step, we will create auth scaffold command to create login, register and dashboard. so run following commands:
Using Bootstrap:
Step 5 : Create Model
In this step i will create a Post model using following command.
Run bellow command for Comment model:
Step 6 : Create Route
now, we require to create a route for HomeController in laravel application. so open your "routes/web.php" file and add the following route.
Step 7 : Create Controller
Create CommentController using bellow command:
Step 8 : Create Blade File
In this step we have to create a blade file. So finally you have to create the following file and put bellow code:
index.blade.php
create.blade.php
show.blade.php
commentsDisplay.blade.php
Path : /resources/views/post/index.blade.php
Path : /resources/views/post/create.blade.php
Path : /resources/views/post/show.blade.php
Path : /resources/views/post/commentsDisplay.blade.php
Now we are ready to run our example so run bellow command for quick run:
Post Page

Comment Page

Last updated
Was this helpful?