Page Stubs and Click-Through Flow
This commit is contained in:
56
app/Http/Controllers/ScreeningController.php
Normal file
56
app/Http/Controllers/ScreeningController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Screening;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
final class ScreeningController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new screening session for the authenticated user.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$screening = Screening::create([
|
||||
'user_id' => auth()->id(),
|
||||
]);
|
||||
|
||||
return redirect()->route('screening.show', $screening);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the screening questionnaire.
|
||||
*/
|
||||
public function show(Screening $screening): Response
|
||||
{
|
||||
return Inertia::render('Screening/Show', [
|
||||
'screening' => $screening,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save screening answers and redirect to result.
|
||||
*/
|
||||
public function update(Request $request, Screening $screening): RedirectResponse
|
||||
{
|
||||
return redirect()->route('screening.result', $screening);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the screening result with available categories.
|
||||
*/
|
||||
public function result(Screening $screening): Response
|
||||
{
|
||||
return Inertia::render('Screening/Result', [
|
||||
'screening' => $screening,
|
||||
'categories' => Category::orderBy('sort_order')->get(['id', 'name']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user