slink/laravel/routes/web.php

51 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2024-06-09 20:31:11 +00:00
<?php
use App\Http\Controllers\Link_interactionController;
2024-06-09 20:31:11 +00:00
use Illuminate\Support\Facades\Route;
2024-06-09 21:45:57 +00:00
use App\Http\Controllers\RegisterController;
2024-06-09 22:03:34 +00:00
use App\Http\Controllers\LoginController;
2024-06-10 03:31:51 +00:00
use App\Http\Controllers\ShortlinkController;
2024-06-09 20:31:11 +00:00
Route::get('/', function () {
return redirect('/home');
2024-06-09 20:31:11 +00:00
});
2024-06-09 21:45:57 +00:00
Route::get('/register', function () {
2024-06-10 00:31:46 +00:00
if (!auth()->check()) {
return view('register');
}
return view('profile');
2024-06-09 21:45:57 +00:00
});
2024-06-09 22:03:34 +00:00
Route::post('/register', [RegisterController::class, 'create']);
Route::get('/login', function () {
2024-06-10 00:31:46 +00:00
if (!auth()->check()) {
return view('login');
}
return view('profile');
2024-06-09 22:03:34 +00:00
});
Route::post('/login', [LoginController::class, 'login']);
Route::get('/logout', function () {
auth()->logout();
return redirect('home');
2024-06-09 22:03:34 +00:00
});
2024-06-10 22:29:22 +00:00
Route::get('/profile', [ShortlinkController::class, 'getLinksByUser']);
2024-06-10 00:31:46 +00:00
Route::get('/home', function () {
if (!auth()->check()) {
return view('home');
}
return view('home');
2024-06-10 03:31:51 +00:00
});
Route::post('/shorten', [ShortlinkController::class, 'create']);
2024-06-10 22:29:22 +00:00
Route::post('/l/{id}/update', [ShortlinkController::class, 'update']);
Route::get('/l/{id}', [ShortlinkController::class, 'getDetails']);
2024-06-10 03:31:51 +00:00
Route::get('/{id}', [ShortlinkController::class, 'goto']);