mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-25 07:50:35 -05:00
chore: improve routes
- use inertia() helper - add additional validation rule. - simulate a delay of the server response.
This commit is contained in:
+15
-6
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user