chore: improve routes

- use inertia() helper
- add additional validation rule.
- simulate a delay of the server response.
This commit is contained in:
peaklabs-dev
2025-09-12 18:38:19 +02:00
parent de634ab10f
commit 764599cf35
+15 -6
View File
@@ -3,6 +3,7 @@
declare(strict_types=1);
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
@@ -20,35 +21,40 @@ Route::get('/vue-inertia-test', fn () => Inertia::render('InertiaFormTest', [
]))->name('inertia.form.test');
// Svelte routes
Route::get('/svelte-way-1', fn () => Inertia::render('Svelte/Way1TanStack', [
Route::get('/svelte-way-1', fn () => inertia('Svelte/Way1TanStack', [
'username' => 'Test User',
'notifications_enabled' => true,
]))->name('svelte.way.1');
Route::get('/svelte-way-1-with-state', fn () => Inertia::render('Svelte/Way1TanStackWithState', [
Route::get('/svelte-way-1-with-state', fn () => inertia('Svelte/Way1TanStackWithState', [
'username' => 'Test User',
'notifications_enabled' => true,
]))->name('svelte.way.1.with.state');
Route::get('/svelte-way-2', fn () => Inertia::render('Svelte/Way2TanStack', [
Route::get('/svelte-way-2', fn () => inertia('Svelte/Way2TanStack', [
'username' => 'Test User',
'notifications_enabled' => true,
]))->name('svelte.way.2');
Route::get('/svelte-way-3', fn () => Inertia::render('Svelte/Way3TanStack', [
Route::get('/svelte-way-3', fn () => inertia('Svelte/Way3TanStack', [
'username' => 'Test User',
'notifications_enabled' => true,
]))->name('svelte.way.3');
Route::get('/svelte-way-4', fn () => Inertia::render('Svelte/Way4InertiaForm', [
Route::get('/svelte-way-4', fn () => inertia('Svelte/Way4InertiaForm', [
'username' => 'Test User',
'notifications_enabled' => true,
]))->name('svelte.way.4');
Route::get('/svelte-way-5', fn () => inertia('Svelte/Way5InertiaUseForm', [
'username' => 'Test User',
'notifications_enabled' => true,
]))->name('svelte.way.5');
// Test form route
Route::post('/test-form', function (Request $request) {
$validated = $request->validate([
'username' => ['required', 'string', 'max:255'],
'username' => ['required', 'alpha:ascii', 'min:1', 'max:4'],
'notifications_enabled' => ['boolean'],
]);
@@ -56,5 +62,8 @@ Route::post('/test-form', function (Request $request) {
'validated_data' => $validated,
]);
// simulate a delay
sleep(2);
return redirect()->back()->with('message', 'Settings saved successfully! (This is a flash message from the server)');
})->name('submit.test.form');