From b081d23f8823c1e547054443aa65731888a13b70 Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Fri, 12 Dec 2025 11:00:00 +0800 Subject: [PATCH] Configure application routes Set up all routes for authentication, communities, posts, comments, and voting. Organized routes with proper middleware for authenticated users. --- routes/web.php | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/routes/web.php b/routes/web.php index 86a06c5..d8f1c41 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,41 @@ name('home'); + +Route::get('/register', [AuthController::class, 'showRegister'])->name('register'); +Route::post('/register', [AuthController::class, 'register']); +Route::get('/login', [AuthController::class, 'showLogin'])->name('login'); +Route::post('/login', [AuthController::class, 'login']); +Route::post('/logout', [AuthController::class, 'logout'])->name('logout'); + +Route::get('/communities', [CommunityController::class, 'index'])->name('communities.index'); +Route::get('/r/{community}', [CommunityController::class, 'show'])->name('communities.show'); + +Route::middleware('auth')->group(function () { + Route::get('/communities/create', [CommunityController::class, 'create'])->name('communities.create'); + Route::post('/communities', [CommunityController::class, 'store'])->name('communities.store'); + Route::post('/r/{community}/subscribe', [CommunityController::class, 'subscribe'])->name('communities.subscribe'); + Route::post('/r/{community}/unsubscribe', [CommunityController::class, 'unsubscribe'])->name('communities.unsubscribe'); + + Route::get('/posts/create', [PostController::class, 'create'])->name('posts.create'); + Route::post('/posts', [PostController::class, 'store'])->name('posts.store'); + Route::delete('/posts/{post}', [PostController::class, 'destroy'])->name('posts.destroy'); + + Route::post('/posts/{post}/comments', [CommentController::class, 'store'])->name('comments.store'); + Route::delete('/comments/{comment}', [CommentController::class, 'destroy'])->name('comments.destroy'); + + Route::post('/posts/{post}/vote', [VoteController::class, 'votePost'])->name('posts.vote'); + Route::post('/comments/{comment}/vote', [VoteController::class, 'voteComment'])->name('comments.vote'); }); + +Route::get('/posts/{post}', [PostController::class, 'show'])->name('posts.show'); +Route::get('/u/{user}', [UserController::class, 'show'])->name('users.show');