slink/laravel/routes/web.php

53 lines
1.1 KiB
PHP
Raw Normal View History

2024-06-09 20:31:11 +00:00
<?php
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 view('welcome');
});
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();
2024-06-10 00:31:46 +00:00
return redirect('/home');
2024-06-09 22:03:34 +00:00
});
Route::get('/profile', function () {
if (!auth()->check()) {
2024-06-10 00:31:46 +00:00
return redirect('/home');
2024-06-09 22:03:34 +00:00
}
return view('profile');
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']);
// Route::get('/l/{id}', );
Route::get('/{id}', [ShortlinkController::class, 'goto']);