Compare commits
20 Commits
c693cde038
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0327b95568 | |||
| 9d61186c72 | |||
| 953afd02e6 | |||
| f1824ff752 | |||
| 78c51d55b5 | |||
| 514f1cb483 | |||
| 77edd1b666 | |||
| fb1c28a0ba | |||
| c39b8085af | |||
| eb43b35873 | |||
| f57bdd68da | |||
| e4b3689e64 | |||
| 84355f2463 | |||
| e4259978de | |||
| 9a10ff4727 | |||
| 4dc64c22cb | |||
| ebaeb1722d | |||
| 07a8276899 | |||
| bc1d5a2796 | |||
| baa43de4e1 |
@@ -28,7 +28,10 @@
|
||||
"mcp__playwright__browser_run_code",
|
||||
"mcp__playwright__browser_wait_for",
|
||||
"WebFetch(domain:www.bakertilly.nl)",
|
||||
"mcp__playwright__browser_type"
|
||||
"mcp__playwright__browser_type",
|
||||
"mcp__playwright__browser_hover",
|
||||
"mcp__playwright__browser_evaluate",
|
||||
"mcp__playwright__browser_press_key"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
22
.env.example
@@ -1,8 +1,8 @@
|
||||
APP_NAME=Laravel
|
||||
APP_NAME="Go No Go"
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_URL=http://go-no-go.test
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
@@ -20,12 +20,12 @@ LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=go-no-go
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
@@ -63,3 +63,9 @@ AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
||||
AZURE_CLIENT_ID=
|
||||
AZURE_CLIENT_SECRET=
|
||||
AZURE_REDIRECT_URI=/auth/callback
|
||||
AZURE_TENANT_ID=common
|
||||
NOVA_LICENSE_KEY=
|
||||
|
||||
BIN
.playwright-mcp/element-2026-02-19T13-33-20-065Z.png
Normal file
|
After Width: | Height: | Size: 479 KiB |
BIN
.playwright-mcp/element-2026-02-19T13-37-44-734Z.png
Normal file
|
After Width: | Height: | Size: 479 KiB |
BIN
.playwright-mcp/element-2026-02-19T13-40-05-307Z.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
.playwright-mcp/element-2026-02-19T13-40-12-397Z.png
Normal file
|
After Width: | Height: | Size: 70 KiB |
BIN
.playwright-mcp/go-no-go-1.pdf
Normal file
BIN
.playwright-mcp/page-2026-02-19T13-34-20-685Z.png
Normal file
|
After Width: | Height: | Size: 511 KiB |
86
app/Console/Commands/DevMenuCommand.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
final class DevMenuCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'menu';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Developer tools menu';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
if (! in_array(app()->environment(), ['local', 'testing'])) {
|
||||
$this->error('This command can only be run in local or testing environments.');
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$this->info('');
|
||||
$this->info(' ╔═══════════════════════════════╗');
|
||||
$this->info(' ║ Go No Go — Dev Tools ║');
|
||||
$this->info(' ╚═══════════════════════════════╝');
|
||||
$this->info('');
|
||||
|
||||
$choice = $this->choice('Select an action', [
|
||||
0 => 'Exit',
|
||||
1 => 'Fresh migrate, seed & build',
|
||||
]);
|
||||
|
||||
if ($choice === 'Exit') {
|
||||
$this->info('Bye!');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
if ($choice === 'Fresh migrate, seed & build') {
|
||||
$this->freshMigrateAndBuild();
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs migrate:fresh with seeding, then runs npm build.
|
||||
*
|
||||
* Displays output from both processes and confirms success or failure.
|
||||
*/
|
||||
private function freshMigrateAndBuild(): void
|
||||
{
|
||||
$this->info('');
|
||||
$this->comment('Running migrate:fresh --seed...');
|
||||
$this->call('migrate:fresh', ['--seed' => true]);
|
||||
|
||||
$this->info('');
|
||||
$this->comment('Running npm run build...');
|
||||
|
||||
$process = new Process(['npm', 'run', 'build']);
|
||||
$process->setWorkingDirectory(base_path());
|
||||
$process->setTimeout(120);
|
||||
$process->run(function (string $type, string $output): void {
|
||||
$this->output->write($output);
|
||||
});
|
||||
|
||||
if ($process->isSuccessful()) {
|
||||
$this->info('');
|
||||
$this->info('Environment rebuilt successfully.');
|
||||
} else {
|
||||
$this->error('Build failed.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use App\Services\ActivityLogger;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -29,17 +30,26 @@ public function callback(): RedirectResponse
|
||||
{
|
||||
$azureUser = Socialite::driver('azure')->user();
|
||||
|
||||
$user = User::query()->firstOrCreate(
|
||||
$user = User::query()->updateOrCreate(
|
||||
['email' => $azureUser->getEmail()],
|
||||
[
|
||||
'name' => $azureUser->getName(),
|
||||
'password' => null,
|
||||
'azure_id' => $azureUser->getId(),
|
||||
'photo' => $azureUser->getAvatar(),
|
||||
'job_title' => Arr::get($azureUser->user, 'jobTitle'),
|
||||
'department' => Arr::get($azureUser->user, 'department'),
|
||||
'company_name' => Arr::get($azureUser->user, 'companyName'),
|
||||
'phone' => Arr::get($azureUser->user, 'mobilePhone', Arr::get($azureUser->user, 'businessPhones.0')),
|
||||
]
|
||||
);
|
||||
|
||||
if ($user->role_id === null) {
|
||||
$user->update(['role_id' => Role::where('name', 'user')->first()->id]);
|
||||
}
|
||||
|
||||
auth()->login($user);
|
||||
|
||||
ActivityLogger::log('login', $user->id, metadata: ['email' => $user->email, 'firm_name' => Arr::get($azureUser, 'companyName')]);
|
||||
ActivityLogger::log('login', $user->id, metadata: ['email' => $user->email, 'firm_name' => Arr::get($azureUser->user, 'companyName')]);
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
use App\Models\Session;
|
||||
use App\Services\ActivityLogger;
|
||||
use App\Services\ScoringService;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Inertia\Response as InertiaResponse;
|
||||
|
||||
final class SessionController extends Controller
|
||||
{
|
||||
@@ -36,7 +39,7 @@ public function store(Request $request): RedirectResponse
|
||||
/**
|
||||
* Display the session questionnaire with category, question groups, questions, and existing answers.
|
||||
*/
|
||||
public function show(Session $session): Response
|
||||
public function show(Session $session): InertiaResponse
|
||||
{
|
||||
$session->load('category', 'user');
|
||||
|
||||
@@ -50,14 +53,10 @@ public function show(Session $session): Response
|
||||
|
||||
$answers = $session->answers()->get()->keyBy('question_id');
|
||||
|
||||
$scoringService = new ScoringService;
|
||||
$score = $scoringService->calculateScore($session);
|
||||
|
||||
return Inertia::render('Session/Show', [
|
||||
'session' => $session,
|
||||
'questionGroups' => $questionGroups,
|
||||
'answers' => $answers,
|
||||
'score' => $score,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -66,11 +65,9 @@ public function show(Session $session): Response
|
||||
*/
|
||||
public function update(UpdateSessionRequest $request, Session $session): RedirectResponse
|
||||
{
|
||||
$validated = $request->validated();
|
||||
sleep(3);
|
||||
|
||||
if (Arr::has($validated, 'basic_info')) {
|
||||
$session->update(['basic_info' => Arr::get($validated, 'basic_info')]);
|
||||
}
|
||||
$validated = $request->validated();
|
||||
|
||||
if (Arr::has($validated, 'answers')) {
|
||||
$this->saveAnswers($session, Arr::get($validated, 'answers'));
|
||||
@@ -113,6 +110,8 @@ private function saveAnswers(Session $session, array $answers): void
|
||||
*/
|
||||
private function completeSession(Session $session): RedirectResponse
|
||||
{
|
||||
$this->validateSessionCompletion($session);
|
||||
|
||||
$scoringService = new ScoringService;
|
||||
$score = $scoringService->calculateScore($session);
|
||||
$result = $scoringService->determineResult($score);
|
||||
@@ -129,10 +128,80 @@ private function completeSession(Session $session): RedirectResponse
|
||||
return redirect()->route('sessions.result', $session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that all required fields are answered before session completion.
|
||||
*/
|
||||
private function validateSessionCompletion(Session $session): void
|
||||
{
|
||||
$session->load(['category.questionGroups.questions', 'answers']);
|
||||
|
||||
$errors = [];
|
||||
|
||||
foreach ($session->category->questionGroups as $questionGroup) {
|
||||
foreach ($questionGroup->questions as $question) {
|
||||
$answer = $session->answers->firstWhere('question_id', $question->id);
|
||||
|
||||
$this->validateRadioAnswer($question, $answer, $errors);
|
||||
$this->validateDetailsAnswer($question, $answer, $errors);
|
||||
}
|
||||
}
|
||||
|
||||
if (Arr::exists($errors, 0)) {
|
||||
throw ValidationException::withMessages([
|
||||
'complete' => $errors,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that radio button questions have an answer selected.
|
||||
*/
|
||||
private function validateRadioAnswer($question, $answer, array &$errors): void
|
||||
{
|
||||
$hasRadioButtons = $question->has_yes || $question->has_no || $question->has_na;
|
||||
|
||||
if ($hasRadioButtons && (! $answer || $answer->value === null)) {
|
||||
$errors[] = "Question '{$question->text}' requires an answer.";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that questions with required details have text values provided.
|
||||
*/
|
||||
private function validateDetailsAnswer($question, $answer, array &$errors): void
|
||||
{
|
||||
$details = $question->details;
|
||||
$hasRadioButtons = $question->has_yes || $question->has_no || $question->has_na;
|
||||
|
||||
if ($details === 'required') {
|
||||
if (! $answer || empty(trim(Arr::get($answer->toArray(), 'text_value', '')))) {
|
||||
$errors[] = "Question '{$question->text}' requires details to be provided.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($details === 'req_on_yes' && $answer && $answer->value === 'yes') {
|
||||
if (empty(trim(Arr::get($answer->toArray(), 'text_value', '')))) {
|
||||
$errors[] = "Question '{$question->text}' requires details when answered 'Yes'.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($details === 'req_on_no' && $answer && $answer->value === 'no') {
|
||||
if (empty(trim(Arr::get($answer->toArray(), 'text_value', '')))) {
|
||||
$errors[] = "Question '{$question->text}' requires details when answered 'No'.";
|
||||
}
|
||||
}
|
||||
|
||||
if (! $hasRadioButtons && $details !== null && $details !== '' && $details !== 'optional') {
|
||||
if (! $answer || empty(trim(Arr::get($answer->toArray(), 'text_value', '')))) {
|
||||
$errors[] = "Question '{$question->text}' requires a text response.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the final session result.
|
||||
*/
|
||||
public function result(Session $session): Response
|
||||
public function result(Session $session): InertiaResponse
|
||||
{
|
||||
$session->load('category');
|
||||
|
||||
@@ -143,4 +212,30 @@ public function result(Session $session): Response
|
||||
'categoryName' => $session->category->name,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and download a PDF export of the completed session result.
|
||||
*/
|
||||
public function pdf(Session $session): Response
|
||||
{
|
||||
abort_unless($session->user_id === auth()->id(), 403);
|
||||
abort_unless($session->status === 'completed', 403);
|
||||
|
||||
$session->load(['user', 'category', 'answers.question']);
|
||||
|
||||
$questionGroups = $session->category
|
||||
->questionGroups()
|
||||
->with(['questions' => fn ($q) => $q->orderBy('sort_order')])
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
|
||||
ActivityLogger::log('session_pdf_downloaded', $session->user_id, sessionId: $session->id, categoryId: $session->category_id);
|
||||
|
||||
$pdf = Pdf::loadView('pdf.session-result', [
|
||||
'session' => $session,
|
||||
'questionGroups' => $questionGroups,
|
||||
]);
|
||||
|
||||
return $pdf->download("go-no-go-{$session->id}.pdf");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Inertia\Middleware;
|
||||
use Laravel\Nova\Nova;
|
||||
|
||||
final class HandleInertiaRequests extends Middleware
|
||||
{
|
||||
@@ -32,6 +34,7 @@ public function share(Request $request): array
|
||||
...parent::share($request),
|
||||
'auth' => [
|
||||
'user' => $this->getAuthenticatedUser(),
|
||||
'logo_href' => $this->getLogoHref(),
|
||||
],
|
||||
'flash' => [
|
||||
'success' => fn () => Arr::get($request->session()->all(), 'success'),
|
||||
@@ -55,6 +58,22 @@ private function getAuthenticatedUser(): ?array
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'job_title' => $user->job_title,
|
||||
'company_name' => $user->company_name,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine logo href based on user Nova access.
|
||||
*/
|
||||
private function getLogoHref(): string
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user !== null && Gate::allows('viewNova', $user)) {
|
||||
return Nova::path();
|
||||
}
|
||||
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ final class UpdateScreeningRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->route('screening')->user_id === auth()->id();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@ final class UpdateSessionRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return $this->route('session')->user_id === auth()->id();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,11 +22,6 @@ public function authorize(): bool
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'basic_info' => ['sometimes', 'required', 'array'],
|
||||
'basic_info.client_name' => ['required_with:basic_info', 'string', 'max:255'],
|
||||
'basic_info.client_contact' => ['required_with:basic_info', 'string', 'max:255'],
|
||||
'basic_info.lead_firm_name' => ['required_with:basic_info', 'string', 'max:255'],
|
||||
'basic_info.lead_firm_contact' => ['required_with:basic_info', 'string', 'max:255'],
|
||||
'answers' => ['sometimes', 'array'],
|
||||
'answers.*.value' => ['nullable', 'string', 'in:yes,no,not_applicable'],
|
||||
'answers.*.text_value' => ['nullable', 'string', 'max:10000'],
|
||||
@@ -41,20 +36,6 @@ public function rules(): array
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'basic_info.required' => 'Basic information is required.',
|
||||
'basic_info.array' => 'Basic information must be a valid data structure.',
|
||||
'basic_info.client_name.required_with' => 'The client name is required.',
|
||||
'basic_info.client_name.string' => 'The client name must be text.',
|
||||
'basic_info.client_name.max' => 'The client name cannot exceed 255 characters.',
|
||||
'basic_info.client_contact.required_with' => 'The client contact is required.',
|
||||
'basic_info.client_contact.string' => 'The client contact must be text.',
|
||||
'basic_info.client_contact.max' => 'The client contact cannot exceed 255 characters.',
|
||||
'basic_info.lead_firm_name.required_with' => 'The lead firm name is required.',
|
||||
'basic_info.lead_firm_name.string' => 'The lead firm name must be text.',
|
||||
'basic_info.lead_firm_name.max' => 'The lead firm name cannot exceed 255 characters.',
|
||||
'basic_info.lead_firm_contact.required_with' => 'The lead firm contact is required.',
|
||||
'basic_info.lead_firm_contact.string' => 'The lead firm contact must be text.',
|
||||
'basic_info.lead_firm_contact.max' => 'The lead firm contact cannot exceed 255 characters.',
|
||||
'answers.array' => 'Answers must be a valid data structure.',
|
||||
'answers.*.value.in' => 'Answer value must be yes, no, or not_applicable.',
|
||||
'answers.*.text_value.string' => 'Answer text must be text.',
|
||||
|
||||
40
app/Jobs/CloseSessionsJob.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Session;
|
||||
use App\Services\ActivityLogger;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
final class CloseSessionsJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Find all in-progress sessions idle for more than 12 hours and mark them as
|
||||
* 'unfinished' status, logging each closure individually via ActivityLogger.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
Session::query()
|
||||
->where('status', 'in_progress')
|
||||
->where('created_at', '<', now()->subHours(12))
|
||||
->each(function (Session $session): void {
|
||||
$session->update([
|
||||
'status' => 'unfinished',
|
||||
'completed_at' => now(),
|
||||
]);
|
||||
|
||||
ActivityLogger::log(
|
||||
'session_auto_closed',
|
||||
$session->user_id,
|
||||
sessionId: $session->id,
|
||||
categoryId: $session->category_id,
|
||||
metadata: ['reason' => 'idle_12h'],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
24
app/Jobs/LogAppVersionJob.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
final class LogAppVersionJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Log the application version.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$version = config('app.version', 'unknown');
|
||||
|
||||
Log::info("Application version: {$version}");
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
final class Answer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Fillable attributes for mass assignment.
|
||||
*/
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class Category extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Fillable attributes for mass assignment.
|
||||
*/
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
final class Log extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Disable the updated_at timestamp for append-only logs.
|
||||
*/
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class Question extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Fillable attributes for mass assignment.
|
||||
*/
|
||||
@@ -45,4 +49,12 @@ public function questionGroup(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(QuestionGroup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all answers for this question.
|
||||
*/
|
||||
public function answers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Answer::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class QuestionGroup extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Fillable attributes for mass assignment.
|
||||
*/
|
||||
|
||||
23
app/Models/Role.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class Role extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all users with this role.
|
||||
*/
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class Screening extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Fillable attributes for mass assignment.
|
||||
*/
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
final class ScreeningAnswer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Fillable attributes for mass assignment.
|
||||
*/
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class Session extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'questionnaire_sessions';
|
||||
|
||||
/**
|
||||
@@ -22,7 +25,6 @@ final class Session extends Model
|
||||
'status',
|
||||
'score',
|
||||
'result',
|
||||
'basic_info',
|
||||
'additional_comments',
|
||||
'completed_at',
|
||||
];
|
||||
@@ -37,7 +39,6 @@ protected function casts(): array
|
||||
'category_id' => 'integer',
|
||||
'screening_id' => 'integer',
|
||||
'score' => 'integer',
|
||||
'basic_info' => 'array',
|
||||
'completed_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@@ -23,6 +24,13 @@ final class User extends Authenticatable
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'azure_id',
|
||||
'photo',
|
||||
'job_title',
|
||||
'department',
|
||||
'company_name',
|
||||
'phone',
|
||||
'role_id',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -33,6 +41,7 @@ final class User extends Authenticatable
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
'azure_id',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -45,9 +54,18 @@ protected function casts(): array
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
'role_id' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the role assigned to this user.
|
||||
*/
|
||||
public function role(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Role::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all sessions for this user.
|
||||
*/
|
||||
|
||||
73
app/Nova/Actions/DownloadExcel.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Nova\Actions;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel as BaseDownloadExcel;
|
||||
|
||||
// Fixes Nova 5 incompatibility where field names are PendingTranslation objects instead of strings.
|
||||
final class DownloadExcel extends BaseDownloadExcel
|
||||
{
|
||||
protected $onlyIndexFields = false;
|
||||
/**
|
||||
* @param Model|mixed $row
|
||||
*/
|
||||
public function map($row): array
|
||||
{
|
||||
$only = array_map('strval', $this->getOnly());
|
||||
$except = $this->getExcept();
|
||||
|
||||
if ($row instanceof Model) {
|
||||
if (!$this->onlyIndexFields && $except === null && (!is_array($only) || count($only) === 0)) {
|
||||
$except = $row->getHidden();
|
||||
}
|
||||
|
||||
$row->setHidden([]);
|
||||
$row = $this->replaceFieldValuesWhenOnResource($row, $only);
|
||||
}
|
||||
|
||||
if (is_array($only) && count($only) > 0) {
|
||||
$row = Arr::only($row, $only);
|
||||
}
|
||||
|
||||
if (is_array($except) && count($except) > 0) {
|
||||
$row = Arr::except($row, $except);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
protected function replaceFieldValuesWhenOnResource(Model $model, array $only = []): array
|
||||
{
|
||||
$resource = $this->resolveResource($model);
|
||||
$fields = $this->resourceFields($resource);
|
||||
|
||||
$row = [];
|
||||
foreach ($fields as $field) {
|
||||
if (!$this->isExportableField($field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (\in_array($field->attribute, $only, true)) {
|
||||
$row[$field->attribute] = $field->value;
|
||||
} elseif (\in_array((string) $field->name, $only, true)) {
|
||||
$row[(string) $field->name] = $field->value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_diff($only, array_keys($row)) as $attribute) {
|
||||
if ($model->{$attribute}) {
|
||||
$row[$attribute] = $model->{$attribute};
|
||||
} else {
|
||||
$row[$attribute] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$row = array_merge(array_flip($only), $row);
|
||||
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Fields\Textarea;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
|
||||
use App\Nova\Actions\DownloadExcel;
|
||||
|
||||
final class AnswerResource extends Resource
|
||||
{
|
||||
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
@@ -42,6 +43,29 @@ final class AnswerResource extends Resource
|
||||
*/
|
||||
public static $displayInNavigation = false;
|
||||
|
||||
/**
|
||||
* The relationships that should be eager loaded on index queries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $with = ['session', 'question'];
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Answers';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return 'Answer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
@@ -55,31 +79,38 @@ public function fields(NovaRequest $request): array
|
||||
BelongsTo::make('Session', 'session', SessionResource::class)
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('required'),
|
||||
->readonly()
|
||||
->help('The questionnaire session this answer belongs to.'),
|
||||
|
||||
BelongsTo::make('Question', 'question', QuestionResource::class)
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('required'),
|
||||
->readonly()
|
||||
->help('The question that was answered.'),
|
||||
|
||||
Text::make('Value')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('nullable', 'max:255'),
|
||||
->readonly()
|
||||
->help('The selected answer: "yes", "no", or "not_applicable". Empty for open text questions.'),
|
||||
|
||||
Textarea::make('Text Value')
|
||||
->rules('nullable'),
|
||||
->alwaysShow()
|
||||
->readonly()
|
||||
->help('Any written details or free text the user provided for this question.'),
|
||||
|
||||
DateTime::make('Created At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
->filterable()
|
||||
->help('When this answer was first saved.'),
|
||||
|
||||
DateTime::make('Updated At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
->filterable()
|
||||
->help('When this answer was last changed.'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use Laravel\Nova\Fields\Number;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
|
||||
use App\Nova\Actions\DownloadExcel;
|
||||
|
||||
final class CategoryResource extends Resource
|
||||
{
|
||||
@@ -40,7 +40,23 @@ final class CategoryResource extends Resource
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $displayInNavigation = false;
|
||||
public static $displayInNavigation = true;
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Categories';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return 'Category';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
@@ -56,24 +72,16 @@ public function fields(NovaRequest $request): array
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->help('The name of this assessment category, such as Audit, Tax, or Legal.')
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
Number::make('Sort Order')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->help('Controls the display order of categories. Lower numbers appear first.')
|
||||
->rules('required', 'integer'),
|
||||
|
||||
DateTime::make('Created At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
|
||||
DateTime::make('Updated At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
|
||||
HasMany::make('Question Groups', 'questionGroups', QuestionGroupResource::class),
|
||||
|
||||
HasMany::make('Sessions', 'sessions', SessionResource::class),
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Nova\Dashboards;
|
||||
|
||||
use Laravel\Nova\Cards\Help;
|
||||
use App\Nova\Metrics\ScreeningsTrend;
|
||||
use App\Nova\Metrics\SessionsTrend;
|
||||
use App\Nova\Metrics\TotalScreenings;
|
||||
use App\Nova\Metrics\TotalSessions;
|
||||
use Laravel\Nova\Dashboards\Main as Dashboard;
|
||||
|
||||
class Main extends Dashboard
|
||||
final class Main extends Dashboard
|
||||
{
|
||||
/**
|
||||
* Get the cards for the dashboard.
|
||||
@@ -15,7 +20,10 @@ class Main extends Dashboard
|
||||
public function cards(): array
|
||||
{
|
||||
return [
|
||||
new Help,
|
||||
new TotalSessions,
|
||||
new TotalScreenings,
|
||||
new SessionsTrend,
|
||||
new ScreeningsTrend,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
|
||||
use App\Nova\Actions\DownloadExcel;
|
||||
|
||||
final class LogResource extends Resource
|
||||
{
|
||||
@@ -49,6 +49,29 @@ final class LogResource extends Resource
|
||||
*/
|
||||
public static $group = 'Analytics';
|
||||
|
||||
/**
|
||||
* The relationships that should be eager loaded on index queries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $with = ['user', 'session', 'category'];
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return 'Log';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
@@ -63,34 +86,40 @@ public function fields(NovaRequest $request): array
|
||||
->nullable()
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('nullable'),
|
||||
->rules('nullable')
|
||||
->help('The user who performed this action. May be empty for system events.'),
|
||||
|
||||
BelongsTo::make('Session', 'session', SessionResource::class)
|
||||
->nullable()
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('nullable'),
|
||||
->rules('nullable')
|
||||
->help('The questionnaire session related to this action, if any.'),
|
||||
|
||||
BelongsTo::make('Category', 'category', CategoryResource::class)
|
||||
->nullable()
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('nullable'),
|
||||
->rules('nullable')
|
||||
->help('The assessment category related to this action, if any.'),
|
||||
|
||||
Text::make('Action')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('required', 'max:255'),
|
||||
->rules('required', 'max:255')
|
||||
->help('What happened, e.g. "login", "session_started", "answer_saved", "screening_completed".'),
|
||||
|
||||
Code::make('Metadata')
|
||||
->json()
|
||||
->rules('nullable'),
|
||||
->rules('nullable')
|
||||
->help('Additional details about this action in a structured format.'),
|
||||
|
||||
DateTime::make('Created At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
->filterable()
|
||||
->help('When this action occurred.'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
33
app/Nova/Metrics/ScreeningsTrend.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Nova\Metrics;
|
||||
|
||||
use App\Models\Screening;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Laravel\Nova\Metrics\Trend;
|
||||
|
||||
final class ScreeningsTrend extends Trend
|
||||
{
|
||||
public ?int $cacheFor = null;
|
||||
|
||||
public function calculate(NovaRequest $request): mixed
|
||||
{
|
||||
return $this->countByDays($request, Screening::class);
|
||||
}
|
||||
|
||||
public function name(): string
|
||||
{
|
||||
return 'Screenings';
|
||||
}
|
||||
|
||||
public function ranges(): array
|
||||
{
|
||||
return [
|
||||
30 => '30 Days',
|
||||
60 => '60 Days',
|
||||
90 => '90 Days',
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Nova/Metrics/SessionsTrend.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Nova\Metrics;
|
||||
|
||||
use App\Models\Session;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Laravel\Nova\Metrics\Trend;
|
||||
|
||||
final class SessionsTrend extends Trend
|
||||
{
|
||||
public function calculate(NovaRequest $request): mixed
|
||||
{
|
||||
return $this->countByDays($request, Session::class);
|
||||
}
|
||||
|
||||
public function name(): string
|
||||
{
|
||||
return 'Sessions';
|
||||
}
|
||||
|
||||
public function ranges(): array
|
||||
{
|
||||
return [
|
||||
30 => '30 Days',
|
||||
60 => '60 Days',
|
||||
90 => '90 Days',
|
||||
];
|
||||
}
|
||||
|
||||
public $cacheFor = null;
|
||||
}
|
||||
47
app/Nova/Metrics/TotalScreenings.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Nova\Metrics;
|
||||
|
||||
use App\Models\Screening;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Laravel\Nova\Metrics\Value;
|
||||
|
||||
final class TotalScreenings extends Value
|
||||
{
|
||||
/**
|
||||
* Calculate the value of the metric.
|
||||
*/
|
||||
public function calculate(NovaRequest $request): mixed
|
||||
{
|
||||
return $this->count($request, Screening::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable name of the metric.
|
||||
*/
|
||||
public function name(): string
|
||||
{
|
||||
return 'Total Screenings';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ranges available for the metric.
|
||||
*/
|
||||
public function ranges(): array
|
||||
{
|
||||
return [
|
||||
30 => '30 Days',
|
||||
60 => '60 Days',
|
||||
365 => '365 Days',
|
||||
'TODAY' => 'Today',
|
||||
'ALL' => 'All Time',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the amount of time the results should be cached.
|
||||
*/
|
||||
public $cacheFor = null;
|
||||
}
|
||||
35
app/Nova/Metrics/TotalSessions.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Nova\Metrics;
|
||||
|
||||
use App\Models\Session;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Laravel\Nova\Metrics\Value;
|
||||
|
||||
final class TotalSessions extends Value
|
||||
{
|
||||
public function calculate(NovaRequest $request): mixed
|
||||
{
|
||||
return $this->count($request, Session::class);
|
||||
}
|
||||
|
||||
public function name(): string
|
||||
{
|
||||
return 'Total Sessions';
|
||||
}
|
||||
|
||||
public function ranges(): array
|
||||
{
|
||||
return [
|
||||
30 => '30 Days',
|
||||
60 => '60 Days',
|
||||
365 => '365 Days',
|
||||
'TODAY' => 'Today',
|
||||
'ALL' => 'All Time',
|
||||
];
|
||||
}
|
||||
|
||||
public $cacheFor = null;
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Fields\Textarea;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
|
||||
use App\Nova\Actions\DownloadExcel;
|
||||
|
||||
final class QuestionGroupResource extends Resource
|
||||
{
|
||||
@@ -42,7 +42,23 @@ final class QuestionGroupResource extends Resource
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $displayInNavigation = false;
|
||||
public static $displayInNavigation = true;
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Question Groups';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return 'Question Group';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
@@ -57,35 +73,30 @@ public function fields(NovaRequest $request): array
|
||||
BelongsTo::make('Category', 'category', CategoryResource::class)
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('required'),
|
||||
->rules('required')
|
||||
->help('The assessment category this group of questions belongs to, such as Audit or Tax.'),
|
||||
|
||||
Text::make('Name')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('required', 'max:255'),
|
||||
->rules('required', 'max:255')
|
||||
->help('The title of this question group, shown as a section heading in the questionnaire.'),
|
||||
|
||||
Number::make('Sort Order')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('required', 'integer'),
|
||||
->rules('required', 'integer')
|
||||
->help('Controls the display order within the category. Lower numbers appear first.'),
|
||||
|
||||
Textarea::make('Description')
|
||||
->rules('nullable'),
|
||||
->rules('nullable')
|
||||
->help('An optional description shown to users at the top of this question group.'),
|
||||
|
||||
Textarea::make('Scoring Instructions')
|
||||
->rules('nullable'),
|
||||
|
||||
DateTime::make('Created At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
|
||||
DateTime::make('Updated At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
->rules('nullable')
|
||||
->help('Optional instructions shown to users explaining how this section is scored, e.g. "If you answer yes, you will score 1 point."'),
|
||||
|
||||
HasMany::make('Questions', 'questions', QuestionResource::class),
|
||||
];
|
||||
|
||||
@@ -4,15 +4,17 @@
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use App\Nova\Actions\DownloadExcel;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\Boolean;
|
||||
use Laravel\Nova\Fields\DateTime;
|
||||
use Laravel\Nova\Fields\HasMany;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Number;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Fields\Textarea;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
|
||||
|
||||
final class QuestionResource extends Resource
|
||||
{
|
||||
@@ -51,6 +53,22 @@ final class QuestionResource extends Resource
|
||||
*/
|
||||
public static $group = 'Questionnaire';
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Questions';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return 'Question';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
@@ -61,56 +79,60 @@ public function fields(NovaRequest $request): array
|
||||
return [
|
||||
ID::make()->sortable(),
|
||||
|
||||
Text::make('Question', 'text')
|
||||
->displayUsing(fn ($value) => Str::limit($value, 40))
|
||||
->onlyOnIndex()
|
||||
->sortable(),
|
||||
|
||||
BelongsTo::make('Question Group', 'questionGroup', QuestionGroupResource::class)
|
||||
->sortable()
|
||||
->filterable()
|
||||
->readonly(),
|
||||
->help('The group this question belongs to. Questions are shown together by group in the questionnaire.'),
|
||||
|
||||
Textarea::make('Text')
|
||||
->rules('required')
|
||||
->updateRules('required'),
|
||||
->updateRules('required')
|
||||
->help('The full question text shown to the user in the questionnaire.'),
|
||||
|
||||
Boolean::make('Has Yes')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->readonly(),
|
||||
->help('When enabled, a "Yes" answer option is shown for this question.'),
|
||||
|
||||
Boolean::make('Has No')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->readonly(),
|
||||
->help('When enabled, a "No" answer option is shown for this question.'),
|
||||
|
||||
Boolean::make('Has NA', 'has_na')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->readonly(),
|
||||
->help('When enabled, a "Not Applicable" answer option is shown for this question.'),
|
||||
|
||||
Text::make('Details')
|
||||
Select::make('Details')
|
||||
->options([
|
||||
'optional' => 'Optional',
|
||||
'required' => 'Required',
|
||||
'req_on_yes' => 'Required on Yes',
|
||||
'req_on_no' => 'Required on No',
|
||||
])
|
||||
->displayUsingLabels()
|
||||
->nullable()
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->readonly(),
|
||||
->help('Controls when the user is asked for additional details. "Required" always asks, "Optional" lets the user choose, "Required on Yes/No" only asks when that answer is selected.'),
|
||||
|
||||
Number::make('Sort Order')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->readonly(),
|
||||
->help('Controls the display order within the question group. Lower numbers appear first.'),
|
||||
|
||||
Boolean::make('Is Scored')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->readonly(),
|
||||
->help('When enabled, this question counts toward the total score. A "Yes" answer scores 1 point.'),
|
||||
|
||||
DateTime::make('Created At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
|
||||
DateTime::make('Updated At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
HasMany::make('Answers', 'answers', AnswerResource::class),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,17 @@
|
||||
|
||||
abstract class Resource extends NovaResource
|
||||
{
|
||||
public static function perPageOptions()
|
||||
{
|
||||
return [50, 100, 150];
|
||||
}
|
||||
|
||||
public static function perPageViaRelationshipOptions()
|
||||
{
|
||||
return [10, 25, 50];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build an "index" query for the given resource.
|
||||
*/
|
||||
|
||||
75
app/Nova/RoleResource.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use Laravel\Nova\Fields\DateTime;
|
||||
use Laravel\Nova\Fields\HasMany;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
final class RoleResource extends Resource
|
||||
{
|
||||
public static string $model = \App\Models\Role::class;
|
||||
|
||||
public static $title = 'name';
|
||||
|
||||
public static $search = ['id', 'name'];
|
||||
|
||||
public static $displayInNavigation = false;
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Roles';
|
||||
}
|
||||
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return 'Role';
|
||||
}
|
||||
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
ID::make()->sortable(),
|
||||
|
||||
Text::make('Name')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('required', 'max:255'),
|
||||
|
||||
DateTime::make('Created At')
|
||||
->exceptOnForms()
|
||||
->sortable(),
|
||||
|
||||
DateTime::make('Updated At')
|
||||
->exceptOnForms()
|
||||
->sortable(),
|
||||
|
||||
HasMany::make('Users', 'users', User::class),
|
||||
];
|
||||
}
|
||||
|
||||
public function cards(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function filters(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function lenses(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function actions(NovaRequest $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Number;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
|
||||
use App\Nova\Actions\DownloadExcel;
|
||||
|
||||
final class ScreeningResource extends Resource
|
||||
{
|
||||
@@ -50,6 +50,29 @@ final class ScreeningResource extends Resource
|
||||
*/
|
||||
public static $group = 'Questionnaire';
|
||||
|
||||
/**
|
||||
* The relationships that should be eager loaded on index queries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $with = ['user'];
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Screenings';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return 'Screening';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
@@ -63,28 +86,27 @@ public function fields(NovaRequest $request): array
|
||||
BelongsTo::make('User', 'user', User::class)
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('required'),
|
||||
->rules('required')
|
||||
->help('The person who completed this pre-screening.'),
|
||||
|
||||
Number::make('Score')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('required', 'integer'),
|
||||
->rules('required', 'integer')
|
||||
->help('The number of "Yes" answers out of 10 pre-screening questions.'),
|
||||
|
||||
Boolean::make('Passed')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('required', 'boolean'),
|
||||
->rules('required', 'boolean')
|
||||
->help('Whether the user scored 5 or more points and was allowed to continue to the full questionnaire.'),
|
||||
|
||||
DateTime::make('Created At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
|
||||
DateTime::make('Updated At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
->filterable()
|
||||
->help('When this pre-screening was started.'),
|
||||
|
||||
HasMany::make('Sessions', 'sessions', SessionResource::class),
|
||||
];
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use App\Nova\Actions\DownloadExcel;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\Code;
|
||||
use Laravel\Nova\Fields\DateTime;
|
||||
use Laravel\Nova\Fields\HasMany;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Number;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\Textarea;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
|
||||
|
||||
final class SessionResource extends Resource
|
||||
{
|
||||
@@ -52,6 +51,29 @@ final class SessionResource extends Resource
|
||||
*/
|
||||
public static $group = 'Questionnaire';
|
||||
|
||||
/**
|
||||
* The relationships that should be eager loaded on index queries.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $with = ['user', 'category', 'screening'];
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Sessions';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return 'Session';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
@@ -65,58 +87,61 @@ public function fields(NovaRequest $request): array
|
||||
BelongsTo::make('User', 'user', User::class)
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('required'),
|
||||
->rules('required')
|
||||
->help('The person who started this questionnaire session.'),
|
||||
|
||||
BelongsTo::make('Category', 'category', CategoryResource::class)
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('required'),
|
||||
->rules('required')
|
||||
->help('The assessment category for this session, such as Audit or Tax.'),
|
||||
|
||||
BelongsTo::make('Screening', 'screening', ScreeningResource::class)
|
||||
->nullable()
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('nullable'),
|
||||
->rules('nullable')
|
||||
->help('The pre-screening that was completed before starting this session.'),
|
||||
|
||||
Text::make('Status')
|
||||
Select::make('Status')
|
||||
->options([
|
||||
'in_progress' => 'In Progress',
|
||||
'completed' => 'Completed',
|
||||
'unfinished' => 'Unfinished',
|
||||
'abandoned' => 'Abandoned',
|
||||
])
|
||||
->displayUsingLabels()
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('required', 'max:255'),
|
||||
->help('The current state of this session. "In Progress" means the user has not yet submitted, "Completed" means submitted, "Unfinished" means the session was auto-closed after inactivity, "Abandoned" means the user left without finishing.'),
|
||||
|
||||
Number::make('Score')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('nullable', 'integer'),
|
||||
->rules('nullable', 'integer')
|
||||
->help('The total score from all scored questions. Only "Yes" answers count as points.'),
|
||||
|
||||
Text::make('Result')
|
||||
Select::make('Result')
|
||||
->options([
|
||||
'go' => 'Go',
|
||||
'no_go' => 'No Go',
|
||||
'consult_leadership' => 'Consult Leadership',
|
||||
])
|
||||
->displayUsingLabels()
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->rules('nullable', 'max:255'),
|
||||
|
||||
Code::make('Basic Info', 'basic_info')
|
||||
->json()
|
||||
->rules('nullable'),
|
||||
->help('The final outcome based on the score. "Go" (10+ points) means pursue the opportunity, "Consult Leadership" (5-9 points) means seek advice, "No Go" (1-4 points) means do not pursue.'),
|
||||
|
||||
Textarea::make('Additional Comments')
|
||||
->rules('nullable'),
|
||||
->rules('nullable')
|
||||
->help('Any extra notes the user added at the end of the questionnaire.'),
|
||||
|
||||
DateTime::make('Completed At')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->rules('nullable'),
|
||||
|
||||
DateTime::make('Created At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
|
||||
DateTime::make('Updated At')
|
||||
->exceptOnForms()
|
||||
->sortable()
|
||||
->filterable(),
|
||||
->rules('nullable')
|
||||
->help('The date and time when the user submitted this session.'),
|
||||
|
||||
HasMany::make('Answers', 'answers', AnswerResource::class),
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Auth\PasswordValidationRules;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Password;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
@@ -35,7 +36,7 @@ final class User extends Resource
|
||||
* @var array
|
||||
*/
|
||||
public static $search = [
|
||||
'id', 'name', 'email',
|
||||
'id', 'name', 'email', 'department', 'job_title',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -48,20 +49,55 @@ public function fields(NovaRequest $request): array
|
||||
return [
|
||||
ID::make()->sortable(),
|
||||
|
||||
BelongsTo::make('Role', 'role', RoleResource::class)
|
||||
->sortable()
|
||||
->filterable()
|
||||
->help('The user\'s role, which controls what they can access in the admin panel.'),
|
||||
|
||||
Text::make('Name')
|
||||
->sortable()
|
||||
->rules('required', 'max:255'),
|
||||
->rules('required', 'max:255')
|
||||
->help('The user\'s full name, imported from Azure AD when they first log in.'),
|
||||
|
||||
Text::make('Email')
|
||||
->sortable()
|
||||
->rules('required', 'email', 'max:254')
|
||||
->creationRules('unique:users,email')
|
||||
->updateRules('unique:users,email,{{resourceId}}'),
|
||||
->updateRules('unique:users,email,{{resourceId}}')
|
||||
->help('The user\'s email address, used to identify them when logging in via Azure AD.'),
|
||||
|
||||
Text::make('Azure ID', 'azure_id')
|
||||
->onlyOnDetail()
|
||||
->copyable()
|
||||
->help('A unique identifier from Azure AD. Set automatically when the user logs in.'),
|
||||
|
||||
Text::make('Photo', 'photo')
|
||||
->onlyOnDetail()
|
||||
->copyable()
|
||||
->help('A link to the user\'s profile photo from Azure AD.'),
|
||||
|
||||
Text::make('Job Title', 'job_title')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->help('The user\'s job title, imported from Azure AD.'),
|
||||
|
||||
Text::make('Department')
|
||||
->sortable()
|
||||
->filterable()
|
||||
->copyable()
|
||||
->help('The department the user belongs to, imported from Azure AD.'),
|
||||
|
||||
Text::make('Phone')
|
||||
->sortable()
|
||||
->copyable()
|
||||
->help('The user\'s phone number, imported from Azure AD.'),
|
||||
|
||||
Password::make('Password')
|
||||
->onlyOnForms()
|
||||
->creationRules($this->passwordRules())
|
||||
->updateRules($this->optionalPasswordRules()),
|
||||
->updateRules($this->optionalPasswordRules())
|
||||
->help('Only needed for admin panel access. Regular users log in via Azure AD and do not need a password.'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public function view(User $user, Category $category): bool
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ public function create(User $user): bool
|
||||
*/
|
||||
public function update(User $user, Category $category): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ public function view(User $user, QuestionGroup $questionGroup): bool
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ public function create(User $user): bool
|
||||
*/
|
||||
public function update(User $user, QuestionGroup $questionGroup): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ public function view(User $user, Question $question): bool
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use SocialiteProviders\Azure\AzureExtendSocialite;
|
||||
use SocialiteProviders\Manager\SocialiteWasCalled;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
final class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
@@ -16,9 +21,10 @@ public function register(): void
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
* Registers the Microsoft Azure Socialite provider for SSO authentication.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
Event::listen(SocialiteWasCalled::class, AzureExtendSocialite::class.'@handle');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,18 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Nova\CategoryResource;
|
||||
use App\Nova\Dashboards\Main;
|
||||
use App\Nova\LogResource;
|
||||
use App\Nova\QuestionGroupResource;
|
||||
use App\Nova\QuestionResource;
|
||||
use App\Nova\ScreeningResource;
|
||||
use App\Nova\SessionResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Fortify\Features;
|
||||
use Laravel\Nova\Menu\MenuItem;
|
||||
use Laravel\Nova\Menu\MenuSection;
|
||||
use Laravel\Nova\Nova;
|
||||
use Laravel\Nova\NovaApplicationServiceProvider;
|
||||
|
||||
@@ -17,7 +27,27 @@ public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
Nova::mainMenu(function (Request $request) {
|
||||
return [
|
||||
MenuSection::dashboard(Main::class)->icon('home'),
|
||||
|
||||
MenuSection::make('Questionnaire', [
|
||||
MenuItem::resource(QuestionResource::class),
|
||||
MenuItem::resource(QuestionGroupResource::class),
|
||||
MenuItem::resource(CategoryResource::class),
|
||||
MenuItem::resource(SessionResource::class),
|
||||
MenuItem::resource(ScreeningResource::class),
|
||||
])->icon('clipboard-document-list')->collapsible(),
|
||||
|
||||
MenuSection::make('Logs', [
|
||||
MenuItem::resource(LogResource::class),
|
||||
])->icon('chart-bar')->collapsible(),
|
||||
|
||||
MenuSection::make('Users', [
|
||||
MenuItem::resource(\App\Nova\User::class),
|
||||
])->icon('users')->collapsible(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +70,7 @@ protected function fortify(): void
|
||||
protected function routes(): void
|
||||
{
|
||||
Nova::routes()
|
||||
->withAuthenticationRoutes(default: true)
|
||||
->withAuthenticationRoutes(default: false)
|
||||
->withPasswordResetRoutes()
|
||||
->withEmailVerificationRoutes()
|
||||
->register();
|
||||
@@ -54,9 +84,7 @@ protected function routes(): void
|
||||
protected function gate(): void
|
||||
{
|
||||
Gate::define('viewNova', function (User $user) {
|
||||
return in_array($user->email, [
|
||||
'jonathan@blijnder.nl',
|
||||
]);
|
||||
return $user->role?->name === 'admin';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withSchedule(function (\Illuminate\Console\Scheduling\Schedule $schedule): void {
|
||||
$schedule->job(\App\Jobs\CloseSessionsJob::class)->hourly();
|
||||
})
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->web(append: [
|
||||
\App\Http\Middleware\HandleInertiaRequests::class,
|
||||
@@ -22,5 +25,19 @@
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
$exceptions->respond(function (\Symfony\Component\HttpFoundation\Response $response, \Throwable $exception, \Illuminate\Http\Request $request) {
|
||||
if (! app()->environment('local') && in_array($response->getStatusCode(), [403, 404, 500, 503])) {
|
||||
return \Inertia\Inertia::render('ErrorPage', ['status' => $response->getStatusCode()])
|
||||
->toResponse($request)
|
||||
->setStatusCode($response->getStatusCode());
|
||||
}
|
||||
|
||||
if ($response->getStatusCode() === 419) {
|
||||
return back()->with([
|
||||
'message' => 'The page expired, please try again.',
|
||||
]);
|
||||
}
|
||||
|
||||
return $response;
|
||||
});
|
||||
})->create();
|
||||
|
||||
@@ -6,13 +6,15 @@
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"php": "^8.4",
|
||||
"barryvdh/laravel-dompdf": "^3.1",
|
||||
"inertiajs/inertia-laravel": "^2.0",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/nova": "^5.0",
|
||||
"laravel/socialite": "^5.24",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"maatwebsite/laravel-nova-excel": "^1.3"
|
||||
"maatwebsite/laravel-nova-excel": "^1.3",
|
||||
"socialiteproviders/microsoft-azure": "^5.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
|
||||
645
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c5908b1cf6b95103d6009afd8de09581",
|
||||
"content-hash": "0c0fc2f7a9b1735524227daa79192e95",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bacon/bacon-qr-code",
|
||||
@@ -61,6 +61,83 @@
|
||||
},
|
||||
"time": "2025-11-19T17:15:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "barryvdh/laravel-dompdf",
|
||||
"version": "v3.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/barryvdh/laravel-dompdf.git",
|
||||
"reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d",
|
||||
"reference": "8e71b99fc53bb8eb77f316c3c452dd74ab7cb25d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"dompdf/dompdf": "^3.0",
|
||||
"illuminate/support": "^9|^10|^11|^12",
|
||||
"php": "^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"larastan/larastan": "^2.7|^3.0",
|
||||
"orchestra/testbench": "^7|^8|^9|^10",
|
||||
"phpro/grumphp": "^2.5",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"aliases": {
|
||||
"PDF": "Barryvdh\\DomPDF\\Facade\\Pdf",
|
||||
"Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf"
|
||||
},
|
||||
"providers": [
|
||||
"Barryvdh\\DomPDF\\ServiceProvider"
|
||||
]
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Barryvdh\\DomPDF\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Barry vd. Heuvel",
|
||||
"email": "barryvdh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A DOMPDF Wrapper for Laravel",
|
||||
"keywords": [
|
||||
"dompdf",
|
||||
"laravel",
|
||||
"pdf"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/barryvdh/laravel-dompdf/issues",
|
||||
"source": "https://github.com/barryvdh/laravel-dompdf/tree/v3.1.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://fruitcake.nl",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/barryvdh",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-02-13T15:07:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "brick/math",
|
||||
"version": "0.14.4",
|
||||
@@ -695,6 +772,161 @@
|
||||
],
|
||||
"time": "2024-02-05T11:56:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dompdf/dompdf",
|
||||
"version": "v3.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dompdf/dompdf.git",
|
||||
"reference": "db712c90c5b9868df3600e64e68da62e78a34623"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/db712c90c5b9868df3600e64e68da62e78a34623",
|
||||
"reference": "db712c90c5b9868df3600e64e68da62e78a34623",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"dompdf/php-font-lib": "^1.0.0",
|
||||
"dompdf/php-svg-lib": "^1.0.0",
|
||||
"ext-dom": "*",
|
||||
"ext-mbstring": "*",
|
||||
"masterminds/html5": "^2.0",
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-gd": "*",
|
||||
"ext-json": "*",
|
||||
"ext-zip": "*",
|
||||
"mockery/mockery": "^1.3",
|
||||
"phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gd": "Needed to process images",
|
||||
"ext-gmagick": "Improves image processing performance",
|
||||
"ext-imagick": "Improves image processing performance",
|
||||
"ext-zlib": "Needed for pdf stream compression"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Dompdf\\": "src/"
|
||||
},
|
||||
"classmap": [
|
||||
"lib/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "The Dompdf Community",
|
||||
"homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md"
|
||||
}
|
||||
],
|
||||
"description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
|
||||
"homepage": "https://github.com/dompdf/dompdf",
|
||||
"support": {
|
||||
"issues": "https://github.com/dompdf/dompdf/issues",
|
||||
"source": "https://github.com/dompdf/dompdf/tree/v3.1.4"
|
||||
},
|
||||
"time": "2025-10-29T12:43:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dompdf/php-font-lib",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dompdf/php-font-lib.git",
|
||||
"reference": "a6e9a688a2a80016ac080b97be73d3e10c444c9a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/a6e9a688a2a80016ac080b97be73d3e10c444c9a",
|
||||
"reference": "a6e9a688a2a80016ac080b97be73d3e10c444c9a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11 || ^12"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"FontLib\\": "src/FontLib"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "The FontLib Community",
|
||||
"homepage": "https://github.com/dompdf/php-font-lib/blob/master/AUTHORS.md"
|
||||
}
|
||||
],
|
||||
"description": "A library to read, parse, export and make subsets of different types of font files.",
|
||||
"homepage": "https://github.com/dompdf/php-font-lib",
|
||||
"support": {
|
||||
"issues": "https://github.com/dompdf/php-font-lib/issues",
|
||||
"source": "https://github.com/dompdf/php-font-lib/tree/1.0.2"
|
||||
},
|
||||
"time": "2026-01-20T14:10:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dompdf/php-svg-lib",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dompdf/php-svg-lib.git",
|
||||
"reference": "8259ffb930817e72b1ff1caef5d226501f3dfeb1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/8259ffb930817e72b1ff1caef5d226501f3dfeb1",
|
||||
"reference": "8259ffb930817e72b1ff1caef5d226501f3dfeb1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": "^7.1 || ^8.0",
|
||||
"sabberworm/php-css-parser": "^8.4 || ^9.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Svg\\": "src/Svg"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-3.0-or-later"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "The SvgLib Community",
|
||||
"homepage": "https://github.com/dompdf/php-svg-lib/blob/master/AUTHORS.md"
|
||||
}
|
||||
],
|
||||
"description": "A library to read, parse and export to PDF SVG files.",
|
||||
"homepage": "https://github.com/dompdf/php-svg-lib",
|
||||
"support": {
|
||||
"issues": "https://github.com/dompdf/php-svg-lib/issues",
|
||||
"source": "https://github.com/dompdf/php-svg-lib/tree/1.0.2"
|
||||
},
|
||||
"time": "2026-01-02T16:01:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dragonmantank/cron-expression",
|
||||
"version": "v3.6.0",
|
||||
@@ -3300,6 +3532,73 @@
|
||||
},
|
||||
"time": "2022-12-02T22:17:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "masterminds/html5",
|
||||
"version": "2.10.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Masterminds/html5-php.git",
|
||||
"reference": "fcf91eb64359852f00d921887b219479b4f21251"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/fcf91eb64359852f00d921887b219479b4f21251",
|
||||
"reference": "fcf91eb64359852f00d921887b219479b4f21251",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-dom": "*",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8 || ^9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Masterminds\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Matt Butcher",
|
||||
"email": "technosophos@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Matt Farina",
|
||||
"email": "matt@mattfarina.com"
|
||||
},
|
||||
{
|
||||
"name": "Asmir Mustafic",
|
||||
"email": "goetas@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "An HTML5 parser and serializer.",
|
||||
"homepage": "http://masterminds.github.io/html5-php",
|
||||
"keywords": [
|
||||
"HTML5",
|
||||
"dom",
|
||||
"html",
|
||||
"parser",
|
||||
"querypath",
|
||||
"serializer",
|
||||
"xml"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/Masterminds/html5-php/issues",
|
||||
"source": "https://github.com/Masterminds/html5-php/tree/2.10.0"
|
||||
},
|
||||
"time": "2025-07-25T09:04:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "3.10.0",
|
||||
@@ -5182,6 +5481,205 @@
|
||||
],
|
||||
"time": "2025-02-18T12:50:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sabberworm/php-css-parser",
|
||||
"version": "v9.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MyIntervals/PHP-CSS-Parser.git",
|
||||
"reference": "1b363fdbdc6dd0ca0f4bf98d3a4d7f388133f1fb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/1b363fdbdc6dd0ca0f4bf98d3a4d7f388133f1fb",
|
||||
"reference": "1b363fdbdc6dd0ca0f4bf98d3a4d7f388133f1fb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-iconv": "*",
|
||||
"php": "^7.2.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
|
||||
"thecodingmachine/safe": "^1.3 || ^2.5 || ^3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-parallel-lint/php-parallel-lint": "1.4.0",
|
||||
"phpstan/extension-installer": "1.4.3",
|
||||
"phpstan/phpstan": "1.12.28 || 2.1.25",
|
||||
"phpstan/phpstan-phpunit": "1.4.2 || 2.0.7",
|
||||
"phpstan/phpstan-strict-rules": "1.6.2 || 2.0.6",
|
||||
"phpunit/phpunit": "8.5.46",
|
||||
"rawr/phpunit-data-provider": "3.3.1",
|
||||
"rector/rector": "1.2.10 || 2.1.7",
|
||||
"rector/type-perfect": "1.0.0 || 2.1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "for parsing UTF-8 CSS"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "9.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Sabberworm\\CSS\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Raphael Schweikert"
|
||||
},
|
||||
{
|
||||
"name": "Oliver Klee",
|
||||
"email": "github@oliverklee.de"
|
||||
},
|
||||
{
|
||||
"name": "Jake Hotson",
|
||||
"email": "jake.github@qzdesign.co.uk"
|
||||
}
|
||||
],
|
||||
"description": "Parser for CSS Files written in PHP",
|
||||
"homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser",
|
||||
"keywords": [
|
||||
"css",
|
||||
"parser",
|
||||
"stylesheet"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues",
|
||||
"source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v9.1.0"
|
||||
},
|
||||
"time": "2025-09-14T07:37:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "socialiteproviders/manager",
|
||||
"version": "v4.8.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/SocialiteProviders/Manager.git",
|
||||
"reference": "8180ec14bef230ec2351cff993d5d2d7ca470ef4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/SocialiteProviders/Manager/zipball/8180ec14bef230ec2351cff993d5d2d7ca470ef4",
|
||||
"reference": "8180ec14bef230ec2351cff993d5d2d7ca470ef4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
|
||||
"laravel/socialite": "^5.5",
|
||||
"php": "^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.2",
|
||||
"phpunit/phpunit": "^9.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"SocialiteProviders\\Manager\\ServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SocialiteProviders\\Manager\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Andy Wendt",
|
||||
"email": "andy@awendt.com"
|
||||
},
|
||||
{
|
||||
"name": "Anton Komarev",
|
||||
"email": "a.komarev@cybercog.su"
|
||||
},
|
||||
{
|
||||
"name": "Miguel Piedrafita",
|
||||
"email": "soy@miguelpiedrafita.com"
|
||||
},
|
||||
{
|
||||
"name": "atymic",
|
||||
"email": "atymicq@gmail.com",
|
||||
"homepage": "https://atymic.dev"
|
||||
}
|
||||
],
|
||||
"description": "Easily add new or override built-in providers in Laravel Socialite.",
|
||||
"homepage": "https://socialiteproviders.com",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"manager",
|
||||
"oauth",
|
||||
"providers",
|
||||
"socialite"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/socialiteproviders/manager/issues",
|
||||
"source": "https://github.com/socialiteproviders/manager"
|
||||
},
|
||||
"time": "2025-02-24T19:33:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "socialiteproviders/microsoft-azure",
|
||||
"version": "5.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/SocialiteProviders/Microsoft-Azure.git",
|
||||
"reference": "453d62c9d7e3b3b76e94c913fb46e68a33347b16"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/SocialiteProviders/Microsoft-Azure/zipball/453d62c9d7e3b3b76e94c913fb46e68a33347b16",
|
||||
"reference": "453d62c9d7e3b3b76e94c913fb46e68a33347b16",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": "^8.0",
|
||||
"socialiteproviders/manager": "^4.4"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SocialiteProviders\\Azure\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Chris Hemmings",
|
||||
"email": "chris@hemmin.gs"
|
||||
}
|
||||
],
|
||||
"description": "Microsoft Azure OAuth2 Provider for Laravel Socialite",
|
||||
"keywords": [
|
||||
"azure",
|
||||
"laravel",
|
||||
"microsoft",
|
||||
"oauth",
|
||||
"provider",
|
||||
"socialite"
|
||||
],
|
||||
"support": {
|
||||
"docs": "https://socialiteproviders.com/microsoft-azure",
|
||||
"issues": "https://github.com/socialiteproviders/providers/issues",
|
||||
"source": "https://github.com/socialiteproviders/providers"
|
||||
},
|
||||
"time": "2024-03-15T03:02:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/clock",
|
||||
"version": "v8.0.0",
|
||||
@@ -7842,6 +8340,149 @@
|
||||
],
|
||||
"time": "2026-01-01T22:13:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thecodingmachine/safe",
|
||||
"version": "v3.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thecodingmachine/safe.git",
|
||||
"reference": "705683a25bacf0d4860c7dea4d7947bfd09eea19"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thecodingmachine/safe/zipball/705683a25bacf0d4860c7dea4d7947bfd09eea19",
|
||||
"reference": "705683a25bacf0d4860c7dea4d7947bfd09eea19",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-parallel-lint/php-parallel-lint": "^1.4",
|
||||
"phpstan/phpstan": "^2",
|
||||
"phpunit/phpunit": "^10",
|
||||
"squizlabs/php_codesniffer": "^3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/special_cases.php",
|
||||
"generated/apache.php",
|
||||
"generated/apcu.php",
|
||||
"generated/array.php",
|
||||
"generated/bzip2.php",
|
||||
"generated/calendar.php",
|
||||
"generated/classobj.php",
|
||||
"generated/com.php",
|
||||
"generated/cubrid.php",
|
||||
"generated/curl.php",
|
||||
"generated/datetime.php",
|
||||
"generated/dir.php",
|
||||
"generated/eio.php",
|
||||
"generated/errorfunc.php",
|
||||
"generated/exec.php",
|
||||
"generated/fileinfo.php",
|
||||
"generated/filesystem.php",
|
||||
"generated/filter.php",
|
||||
"generated/fpm.php",
|
||||
"generated/ftp.php",
|
||||
"generated/funchand.php",
|
||||
"generated/gettext.php",
|
||||
"generated/gmp.php",
|
||||
"generated/gnupg.php",
|
||||
"generated/hash.php",
|
||||
"generated/ibase.php",
|
||||
"generated/ibmDb2.php",
|
||||
"generated/iconv.php",
|
||||
"generated/image.php",
|
||||
"generated/imap.php",
|
||||
"generated/info.php",
|
||||
"generated/inotify.php",
|
||||
"generated/json.php",
|
||||
"generated/ldap.php",
|
||||
"generated/libxml.php",
|
||||
"generated/lzf.php",
|
||||
"generated/mailparse.php",
|
||||
"generated/mbstring.php",
|
||||
"generated/misc.php",
|
||||
"generated/mysql.php",
|
||||
"generated/mysqli.php",
|
||||
"generated/network.php",
|
||||
"generated/oci8.php",
|
||||
"generated/opcache.php",
|
||||
"generated/openssl.php",
|
||||
"generated/outcontrol.php",
|
||||
"generated/pcntl.php",
|
||||
"generated/pcre.php",
|
||||
"generated/pgsql.php",
|
||||
"generated/posix.php",
|
||||
"generated/ps.php",
|
||||
"generated/pspell.php",
|
||||
"generated/readline.php",
|
||||
"generated/rnp.php",
|
||||
"generated/rpminfo.php",
|
||||
"generated/rrd.php",
|
||||
"generated/sem.php",
|
||||
"generated/session.php",
|
||||
"generated/shmop.php",
|
||||
"generated/sockets.php",
|
||||
"generated/sodium.php",
|
||||
"generated/solr.php",
|
||||
"generated/spl.php",
|
||||
"generated/sqlsrv.php",
|
||||
"generated/ssdeep.php",
|
||||
"generated/ssh2.php",
|
||||
"generated/stream.php",
|
||||
"generated/strings.php",
|
||||
"generated/swoole.php",
|
||||
"generated/uodbc.php",
|
||||
"generated/uopz.php",
|
||||
"generated/url.php",
|
||||
"generated/var.php",
|
||||
"generated/xdiff.php",
|
||||
"generated/xml.php",
|
||||
"generated/xmlrpc.php",
|
||||
"generated/yaml.php",
|
||||
"generated/yaz.php",
|
||||
"generated/zip.php",
|
||||
"generated/zlib.php"
|
||||
],
|
||||
"classmap": [
|
||||
"lib/DateTime.php",
|
||||
"lib/DateTimeImmutable.php",
|
||||
"lib/Exceptions/",
|
||||
"generated/Exceptions/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "PHP core functions that throw exceptions instead of returning FALSE on error",
|
||||
"support": {
|
||||
"issues": "https://github.com/thecodingmachine/safe/issues",
|
||||
"source": "https://github.com/thecodingmachine/safe/tree/v3.4.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/OskarStark",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/shish",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/silasjoisten",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/staabm",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-02-04T18:08:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tijsverkoyen/css-to-inline-styles",
|
||||
"version": "v2.4.0",
|
||||
@@ -10804,7 +11445,7 @@
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": "^8.2"
|
||||
"php": "^8.4"
|
||||
},
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.9.0"
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
'version' => '1.0.0',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|
||||
159
config/fortify.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Fortify\Features;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Guard
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which authentication guard Fortify will use while
|
||||
| authenticating users. This value should correspond with one of your
|
||||
| guards that is already present in your "auth" configuration file.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => 'web',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Password Broker
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which password broker Fortify can use when a user
|
||||
| is resetting their password. This configured value should match one
|
||||
| of your password brokers setup in your "auth" configuration file.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => 'users',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Username / Email
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value defines which model attribute should be considered as your
|
||||
| application's "username" field. Typically, this might be the email
|
||||
| address of the users but you are free to change this value here.
|
||||
|
|
||||
| Out of the box, Fortify expects forgot password and reset password
|
||||
| requests to have a field named 'email'. If the application uses
|
||||
| another name for the field you may define it below as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'username' => 'email',
|
||||
|
||||
'email' => 'email',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Lowercase Usernames
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value defines whether usernames should be lowercased before saving
|
||||
| them in the database, as some database system string fields are case
|
||||
| sensitive. You may disable this for your application if necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'lowercase_usernames' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Home Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the path where users will get redirected during
|
||||
| authentication or password reset when the operations are successful
|
||||
| and the user is authenticated. You are free to change this value.
|
||||
|
|
||||
*/
|
||||
|
||||
'home' => '/home',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Routes Prefix / Subdomain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which prefix Fortify will assign to all the routes
|
||||
| that it registers with the application. If necessary, you may change
|
||||
| subdomain under which all of the Fortify routes will be available.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => '',
|
||||
|
||||
'domain' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fortify Routes Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which middleware Fortify will assign to the routes
|
||||
| that it registers with the application. If necessary, you may change
|
||||
| these middleware but typically this provided default is preferred.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Rate Limiting
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default, Fortify will throttle logins to five requests per minute for
|
||||
| every email and IP address combination. However, if you would like to
|
||||
| specify a custom rate limiter to call then you may specify it here.
|
||||
|
|
||||
*/
|
||||
|
||||
'limiters' => [
|
||||
'login' => 'login',
|
||||
'two-factor' => 'two-factor',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register View Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify if the routes returning views should be disabled as
|
||||
| you may not need them when building your own application. This may be
|
||||
| especially true if you're writing a custom single-page application.
|
||||
|
|
||||
*/
|
||||
|
||||
'views' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Features
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some of the Fortify features are optional. You may disable the features
|
||||
| by removing them from this array. You're free to only remove some of
|
||||
| these features or you can even remove all of these if you need to.
|
||||
|
|
||||
*/
|
||||
|
||||
'features' => [
|
||||
Features::registration(),
|
||||
Features::resetPasswords(),
|
||||
// Features::emailVerification(),
|
||||
Features::updateProfileInformation(),
|
||||
Features::updatePasswords(),
|
||||
Features::twoFactorAuthentication([
|
||||
'confirm' => true,
|
||||
'confirmPassword' => true,
|
||||
// 'window' => 0,
|
||||
]),
|
||||
],
|
||||
|
||||
];
|
||||
12
cypress.config.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineConfig } from 'cypress'
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
baseUrl: 'https://go-no-go.test',
|
||||
supportFile: 'cypress/support/e2e.js',
|
||||
specPattern: 'cypress/e2e/**/*.cy.{js,jsx}',
|
||||
viewportWidth: 1280,
|
||||
viewportHeight: 720,
|
||||
defaultCommandTimeout: 10000,
|
||||
},
|
||||
})
|
||||
43
cypress/e2e/questionnaire-flow.cy.js
Normal file
@@ -0,0 +1,43 @@
|
||||
describe('Questionnaire Flow', () => {
|
||||
beforeEach(() => {
|
||||
cy.resetDatabase()
|
||||
cy.login()
|
||||
})
|
||||
|
||||
it('completes the full questionnaire flow from landing to result', () => {
|
||||
// 1. Landing page — click Continue
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
// 2. Screening — answer all 10 questions with Yes
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="yes"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
cy.get('[data-cy="submit-screening"]').click()
|
||||
|
||||
// 3. Screening result — should pass with 10/10
|
||||
cy.get('[data-cy="result-passed"]').should('exist')
|
||||
cy.get('[data-cy="screening-score"]').should('contain', '10')
|
||||
|
||||
// 4. Select first category (Audit)
|
||||
cy.get('[data-cy="category-select"]').within(() => {
|
||||
cy.contains('button', 'Start').first().click()
|
||||
})
|
||||
|
||||
// 5. Session/Show — should see questionnaire
|
||||
cy.url().should('include', '/sessions/')
|
||||
cy.contains('Questionnaire').should('be.visible')
|
||||
|
||||
// 6. Complete session
|
||||
cy.get('[data-cy="complete-session"]').click()
|
||||
|
||||
// 7. Session result page
|
||||
cy.url().should('include', '/result')
|
||||
cy.get('[data-cy="session-result"]').should('exist')
|
||||
|
||||
// 8. Click Again to go back
|
||||
cy.get('[data-cy="start-new"]').click()
|
||||
cy.url().should('eq', Cypress.config('baseUrl') + '/')
|
||||
})
|
||||
})
|
||||
54
cypress/e2e/result-page.cy.js
Normal file
@@ -0,0 +1,54 @@
|
||||
describe('Result Page', () => {
|
||||
beforeEach(() => {
|
||||
cy.resetDatabase()
|
||||
cy.login()
|
||||
})
|
||||
|
||||
function passScreeningAndStartSession() {
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="yes"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
cy.get('[data-cy="submit-screening"]').click()
|
||||
|
||||
cy.get('[data-cy="category-select"]').within(() => {
|
||||
cy.contains('button', 'Start').first().click()
|
||||
})
|
||||
|
||||
cy.url().should('include', '/sessions/')
|
||||
}
|
||||
|
||||
it('shows session result after completion', () => {
|
||||
passScreeningAndStartSession()
|
||||
|
||||
// Just complete without answering specific questions
|
||||
cy.get('[data-cy="complete-session"]').click()
|
||||
|
||||
cy.url().should('include', '/result')
|
||||
cy.get('[data-cy="session-result"]').should('exist')
|
||||
})
|
||||
|
||||
it('shows the result badge with correct result type', () => {
|
||||
passScreeningAndStartSession()
|
||||
|
||||
cy.get('[data-cy="complete-session"]').click()
|
||||
|
||||
cy.url().should('include', '/result')
|
||||
// Should show one of the result types
|
||||
cy.get('[data-cy="session-result"]').should('exist')
|
||||
cy.get('[data-cy^="result-"]').should('exist')
|
||||
})
|
||||
|
||||
it('can start over from result page', () => {
|
||||
passScreeningAndStartSession()
|
||||
|
||||
cy.get('[data-cy="complete-session"]').click()
|
||||
cy.url().should('include', '/result')
|
||||
|
||||
cy.get('[data-cy="start-new"]').click()
|
||||
cy.url().should('eq', Cypress.config('baseUrl') + '/')
|
||||
})
|
||||
})
|
||||
69
cypress/e2e/scoring-display.cy.js
Normal file
@@ -0,0 +1,69 @@
|
||||
describe('Scoring Display', () => {
|
||||
beforeEach(() => {
|
||||
cy.resetDatabase()
|
||||
cy.login()
|
||||
})
|
||||
|
||||
it('shows No Go result when fewer than 5 yes answers', () => {
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
// Answer 4 yes, 6 no
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="yes"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
for (let i = 5; i <= 10; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="no"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
cy.get('[data-cy="submit-screening"]').click()
|
||||
|
||||
// Should fail
|
||||
cy.get('[data-cy="result-failed"]').should('exist')
|
||||
cy.get('[data-cy="screening-score"]').should('contain', '4')
|
||||
cy.get('[data-cy="category-select"]').should('not.exist')
|
||||
})
|
||||
|
||||
it('passes at boundary with exactly 5 yes answers', () => {
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
// Answer 5 yes, 5 no
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="yes"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
for (let i = 6; i <= 10; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="no"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
cy.get('[data-cy="submit-screening"]').click()
|
||||
|
||||
// Should pass
|
||||
cy.get('[data-cy="result-passed"]').should('exist')
|
||||
cy.get('[data-cy="screening-score"]').should('contain', '5')
|
||||
cy.get('[data-cy="category-select"]').should('exist')
|
||||
})
|
||||
|
||||
it('displays the score correctly', () => {
|
||||
cy.get('[data-cy="start-screening"]').click()
|
||||
|
||||
// Answer 7 yes, 3 no
|
||||
for (let i = 1; i <= 7; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="yes"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
for (let i = 8; i <= 10; i++) {
|
||||
cy.get(`[data-cy="screening-answer-${i}"]`).within(() => {
|
||||
cy.get('[data-cy="no"]').check({ force: true })
|
||||
})
|
||||
}
|
||||
cy.get('[data-cy="submit-screening"]').click()
|
||||
|
||||
cy.get('[data-cy="screening-score"]').should('contain', '7')
|
||||
})
|
||||
})
|
||||
8
cypress/support/commands.js
Normal file
@@ -0,0 +1,8 @@
|
||||
Cypress.Commands.add('login', () => {
|
||||
cy.visit('/login-jonathan')
|
||||
cy.url().should('include', '/')
|
||||
})
|
||||
|
||||
Cypress.Commands.add('resetDatabase', () => {
|
||||
cy.exec('herd php artisan migrate:fresh --seed --force', { timeout: 30000 })
|
||||
})
|
||||
1
cypress/support/e2e.js
Normal file
@@ -0,0 +1 @@
|
||||
import './commands'
|
||||
33
database/factories/AnswerFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Answer;
|
||||
use App\Models\Question;
|
||||
use App\Models\Session;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Answer test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Answer>
|
||||
*/
|
||||
final class AnswerFactory extends Factory
|
||||
{
|
||||
protected $model = Answer::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'session_id' => Session::factory(),
|
||||
'question_id' => Question::factory(),
|
||||
'value' => fake()->randomElement(['yes', 'no', 'not_applicable']),
|
||||
'text_value' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
29
database/factories/CategoryFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Category test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Category>
|
||||
*/
|
||||
final class CategoryFactory extends Factory
|
||||
{
|
||||
protected $model = Category::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->words(2, true),
|
||||
'sort_order' => fake()->numberBetween(0, 10),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
database/factories/LogFactory.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Log;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Log test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Log>
|
||||
*/
|
||||
final class LogFactory extends Factory
|
||||
{
|
||||
protected $model = Log::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'action' => fake()->randomElement([
|
||||
'login',
|
||||
'logout',
|
||||
'session_started',
|
||||
'session_completed',
|
||||
'screening_started',
|
||||
'screening_completed',
|
||||
]),
|
||||
'metadata' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
60
database/factories/QuestionFactory.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Question;
|
||||
use App\Models\QuestionGroup;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Question test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Question>
|
||||
*/
|
||||
final class QuestionFactory extends Factory
|
||||
{
|
||||
protected $model = Question::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'question_group_id' => QuestionGroup::factory(),
|
||||
'text' => fake()->sentence(),
|
||||
'has_yes' => true,
|
||||
'has_no' => true,
|
||||
'has_na' => true,
|
||||
'details' => null,
|
||||
'sort_order' => fake()->numberBetween(0, 10),
|
||||
'is_scored' => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the question is not scored.
|
||||
*/
|
||||
public function nonScored(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'is_scored' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the question is text-only (no yes/no/na options).
|
||||
*/
|
||||
public function textOnly(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'has_yes' => false,
|
||||
'has_no' => false,
|
||||
'has_na' => false,
|
||||
'is_scored' => false,
|
||||
'details' => 'required',
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
database/factories/QuestionGroupFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\QuestionGroup;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating QuestionGroup test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\QuestionGroup>
|
||||
*/
|
||||
final class QuestionGroupFactory extends Factory
|
||||
{
|
||||
protected $model = QuestionGroup::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'category_id' => Category::factory(),
|
||||
'name' => fake()->words(3, true),
|
||||
'sort_order' => fake()->numberBetween(0, 10),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
database/factories/ScreeningAnswerFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Screening;
|
||||
use App\Models\ScreeningAnswer;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating ScreeningAnswer test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ScreeningAnswer>
|
||||
*/
|
||||
final class ScreeningAnswerFactory extends Factory
|
||||
{
|
||||
protected $model = ScreeningAnswer::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'screening_id' => Screening::factory(),
|
||||
'question_number' => fake()->numberBetween(1, 10),
|
||||
'value' => fake()->randomElement(['yes', 'no']),
|
||||
];
|
||||
}
|
||||
}
|
||||
53
database/factories/ScreeningFactory.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Screening;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Screening test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Screening>
|
||||
*/
|
||||
final class ScreeningFactory extends Factory
|
||||
{
|
||||
protected $model = Screening::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'score' => null,
|
||||
'passed' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the screening passed.
|
||||
*/
|
||||
public function passed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'score' => 10,
|
||||
'passed' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the screening failed.
|
||||
*/
|
||||
public function failed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'score' => 3,
|
||||
'passed' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
50
database/factories/SessionFactory.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Session;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Factory for generating Session test data.
|
||||
*
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Session>
|
||||
*/
|
||||
final class SessionFactory extends Factory
|
||||
{
|
||||
protected $model = Session::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'category_id' => Category::factory(),
|
||||
'screening_id' => null,
|
||||
'status' => 'in_progress',
|
||||
'score' => null,
|
||||
'result' => null,
|
||||
'additional_comments' => null,
|
||||
'completed_at' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the session is completed.
|
||||
*/
|
||||
public function completed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'status' => 'completed',
|
||||
'score' => 8,
|
||||
'result' => 'consult_leadership',
|
||||
'completed_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
@@ -9,7 +11,7 @@
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
final class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
@@ -27,8 +29,10 @@ public function definition(): array
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'password' => self::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
'job_title' => fake()->jobTitle(),
|
||||
'company_name' => fake()->company(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
32
database/migrations/0000_00_00_000000_create_roles_table.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$now = now();
|
||||
|
||||
DB::table('roles')->insert([
|
||||
['name' => 'user', 'created_at' => $now, 'updated_at' => $now],
|
||||
['name' => 'admin', 'created_at' => $now, 'updated_at' => $now],
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('roles');
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -13,10 +15,17 @@ public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('role_id')->default(1)->constrained();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('azure_id')->nullable()->unique();
|
||||
$table->string('photo')->nullable();
|
||||
$table->string('job_title')->nullable();
|
||||
$table->string('department')->nullable();
|
||||
$table->string('company_name')->nullable();
|
||||
$table->string('phone')->nullable();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->string('password')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -21,7 +21,6 @@ public function up(): void
|
||||
$table->string('status', 50)->default('in_progress');
|
||||
$table->integer('score')->nullable();
|
||||
$table->string('result', 50)->nullable();
|
||||
$table->json('basic_info')->nullable();
|
||||
$table->text('additional_comments')->nullable();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class JonathanSeeder extends Seeder
|
||||
final class JonathanSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
* Seed the application's database with admin user Jonathan.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$adminRole = Role::where('name', 'admin')->first();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Jonathan',
|
||||
'email' => 'jonathan@blijnder.nl',
|
||||
'email' => 'jonathan.van.rij@agerion.nl',
|
||||
'password' => bcrypt('secret'),
|
||||
'email_verified_at' => now(),
|
||||
'role_id' => $adminRole->id,
|
||||
'job_title' => 'Senior Developer',
|
||||
'company_name' => 'Baker Tilly',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
52
database/seeders/TestCategorySeeder.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
final class TestCategorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed a minimal test category with one question group and five scored questions for quick testing.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$categoryId = DB::table('categories')->insertGetId([
|
||||
'name' => 'Test',
|
||||
'sort_order' => 99,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$groupId = DB::table('question_groups')->insertGetId([
|
||||
'category_id' => $categoryId,
|
||||
'name' => 'Test Group',
|
||||
'sort_order' => 1,
|
||||
'description' => null,
|
||||
'scoring_instructions' => null,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$questions = [];
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$questions[] = [
|
||||
'question_group_id' => $groupId,
|
||||
'text' => "Test question {$i}",
|
||||
'has_yes' => true,
|
||||
'has_no' => true,
|
||||
'has_na' => true,
|
||||
'details' => 'optional',
|
||||
'sort_order' => $i,
|
||||
'is_scored' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
|
||||
DB::table('questions')->insert($questions);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ ### Root Level
|
||||
|
||||
### Frontend
|
||||
|
||||
- `docs/theming-templating-vue.md` - Design tokens, Tailwind config, layout, shared Vue components, icon and scoring color standards
|
||||
- `docs/theming-templating-vue.md` - Design tokens, Tailwind config, layout, shared Vue components, RadioButtonGroup pill buttons, icon and scoring color standards
|
||||
|
||||
### Agents
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ ### Color Palette
|
||||
| Token | Hex | RGB | Tailwind Class | Usage |
|
||||
|-------------|-----------|------------------|-----------------|---------------------------------------------|
|
||||
| Primary | `#d1ec51` | 209, 236, 81 | `bg-primary`, `text-primary` | Buttons (default), accents, highlights |
|
||||
| Primary Dark | `#b5d136` | 181, 209, 54 | `bg-primary-dark`, `text-primary-dark` | Selected/hover state for pill buttons, ~15% darker primary |
|
||||
| Secondary | `#00b7b3` | 0, 183, 179 | `bg-secondary`, `text-secondary` | Button hover states, secondary accents |
|
||||
| Background | `#2b303a` | 43, 48, 58 | `bg-surface` | Page background, card backgrounds |
|
||||
| Text | `#ffffff` | 255, 255, 255 | `text-white` | Primary body text on dark background |
|
||||
@@ -96,6 +97,23 @@ ### QuestionCard
|
||||
- `has_na` -- show N/A button
|
||||
- `details` -- show a text input for additional notes
|
||||
|
||||
### RadioButtonGroup
|
||||
|
||||
Pill-shaped button group that replaces native radio buttons. Options appear as connected segments with rounded outer edges.
|
||||
|
||||
| Prop | Type | Default | Description |
|
||||
|--------------|-------------------------------|---------|--------------------------------|
|
||||
| `modelValue` | `String \| null` | `null` | Selected value (v-model) |
|
||||
| `options` | `Array<{value, label}>` | required | Options to render |
|
||||
| `name` | `String` | required | HTML radio group name |
|
||||
| `disabled` | `Boolean` | `false` | Disables all options |
|
||||
|
||||
Default state: `bg-primary` with `text-gray-900`.
|
||||
Selected & hover state: `bg-primary-dark`.
|
||||
Keyboard focus: visible ring using `ring-primary-dark`.
|
||||
|
||||
Used in `QuestionCard` (3-option: Yes/No/N/A) and `Screening/Show` (2-option: Yes/No).
|
||||
|
||||
## Icons
|
||||
|
||||
Heroicons is the only icon library. No other icon packages.
|
||||
|
||||
BIN
no-pill-centered.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
1603
package-lock.json
generated
@@ -4,12 +4,16 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
"dev": "vite",
|
||||
"cy:open": "cypress open",
|
||||
"cy:run": "cypress run",
|
||||
"test:e2e": "cypress run"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"axios": "^1.11.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"cypress": "^15.9.0",
|
||||
"laravel-vite-plugin": "^2.0.0",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^7.0.7"
|
||||
|
||||
BIN
pdf-preview-after.png
Normal file
|
After Width: | Height: | Size: 512 KiB |
BIN
pdf-preview-before.png
Normal file
|
After Width: | Height: | Size: 511 KiB |
BIN
public/images/growth-symbol.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
@@ -11,6 +11,7 @@ @theme {
|
||||
'Segoe UI Symbol', 'Noto Color Emoji';
|
||||
|
||||
--color-primary: #d1ec51;
|
||||
--color-primary-dark: #b5d136;
|
||||
--color-secondary: #00b7b3;
|
||||
--color-surface: #2b303a;
|
||||
}
|
||||
|
||||
BIN
resources/images/Growth_symbol/Growth Symbol Charcoal EPS.eps
Normal file
BIN
resources/images/Growth_symbol/Growth Symbol Charcoal JPEG.jpg
Normal file
|
After Width: | Height: | Size: 704 KiB |
BIN
resources/images/Growth_symbol/Growth Symbol Charcoal PNG.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
resources/images/Growth_symbol/Growth Symbol REV EPS.eps
Normal file
BIN
resources/images/Growth_symbol/Growth Symbol REV PNG.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
6669
resources/images/Growth_symbol/Growth Symbol_Outline_Charcoal AI.ai
Normal file
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 28 KiB |
BIN
resources/images/Growth_symbol/Transparency 15%.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
resources/images/Growth_symbol/Transparency 40%.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
@@ -18,6 +18,10 @@ const props = defineProps({
|
||||
type: String,
|
||||
default: undefined,
|
||||
},
|
||||
external: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -32,7 +36,11 @@ const emit = defineEmits(['click'])
|
||||
|
||||
const isDisabled = computed(() => props.disabled || props.loading)
|
||||
|
||||
const component = computed(() => props.href ? Link : 'button')
|
||||
const component = computed(() => {
|
||||
if (props.href && props.external) return 'a'
|
||||
if (props.href) return Link
|
||||
return 'button'
|
||||
})
|
||||
|
||||
const buttonClasses = computed(() => {
|
||||
const classes = [
|
||||
@@ -44,11 +52,11 @@ const buttonClasses = computed(() => {
|
||||
|
||||
// Size classes
|
||||
if (props.size === 'sm') {
|
||||
classes.push('px-3 py-1.5 text-sm')
|
||||
classes.push('px-4 py-2 text-sm')
|
||||
} else if (props.size === 'md') {
|
||||
classes.push('px-5 py-2.5 text-base')
|
||||
classes.push('px-6 py-3 text-base')
|
||||
} else if (props.size === 'lg') {
|
||||
classes.push('px-7 py-3 text-lg')
|
||||
classes.push('px-8 py-3.5 text-lg')
|
||||
}
|
||||
|
||||
// Variant classes
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { usePage } from '@inertiajs/vue3'
|
||||
import AppLogo from '@/Components/AppLogo.vue'
|
||||
|
||||
defineProps({
|
||||
@@ -7,12 +9,17 @@ defineProps({
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const page = usePage()
|
||||
const logoHref = computed(() => page.props.auth?.logo_href ?? '/')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="sticky top-0 z-50 bg-surface border-b border-gray-700">
|
||||
<div class="px-6 py-4 flex items-center gap-6">
|
||||
<a :href="logoHref" class="flex items-center">
|
||||
<AppLogo class="text-2xl" />
|
||||
</a>
|
||||
<h1 v-if="title" class="text-xl font-semibold text-white">
|
||||
{{ title }}
|
||||
</h1>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import RadioButtonGroup from '@/Components/RadioButtonGroup.vue'
|
||||
|
||||
const props = defineProps({
|
||||
question: {
|
||||
@@ -10,6 +11,10 @@ const props = defineProps({
|
||||
type: Object,
|
||||
default: () => ({ value: null, text_value: '' }),
|
||||
},
|
||||
error: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
@@ -39,6 +44,14 @@ const isTextOnly = computed(() => {
|
||||
return !hasRadioButtons.value && props.question.details
|
||||
})
|
||||
|
||||
const availableOptions = computed(() => {
|
||||
const opts = []
|
||||
if (props.question.has_yes) opts.push({ value: 'yes', label: 'Yes' })
|
||||
if (props.question.has_no) opts.push({ value: 'no', label: 'No' })
|
||||
if (props.question.has_na) opts.push({ value: 'not_applicable', label: 'N/A' })
|
||||
return opts
|
||||
})
|
||||
|
||||
const updateValue = (value) => {
|
||||
emit('update:modelValue', { ...props.modelValue, value })
|
||||
}
|
||||
@@ -49,8 +62,11 @@ const updateTextValue = (event) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="py-4">
|
||||
<p class="text-white mb-3">{{ question.text }}</p>
|
||||
<div
|
||||
class="py-6 transition-all duration-200"
|
||||
:class="{ 'border-l-2 border-red-400/60 pl-4 -ml-4': error }"
|
||||
>
|
||||
<p class="text-white font-medium leading-relaxed mb-4">{{ question.text }}</p>
|
||||
|
||||
<!-- Text-only question (no radio buttons) -->
|
||||
<div v-if="isTextOnly">
|
||||
@@ -58,50 +74,30 @@ const updateTextValue = (event) => {
|
||||
:value="modelValue.text_value"
|
||||
@input="updateTextValue"
|
||||
rows="3"
|
||||
class="w-full rounded-lg border border-gray-600 bg-surface px-3 py-2 text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary"
|
||||
class="w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-gray-600 focus:border-primary/50 focus:ring-1 focus:ring-primary/20 transition-colors duration-200"
|
||||
placeholder="Enter your response..."
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<!-- Radio button question -->
|
||||
<div v-if="hasRadioButtons">
|
||||
<div class="flex flex-wrap gap-4 mb-3">
|
||||
<label v-if="question.has_yes" class="flex items-center gap-2 cursor-pointer">
|
||||
<input
|
||||
type="radio"
|
||||
<RadioButtonGroup
|
||||
:modelValue="modelValue.value"
|
||||
@update:modelValue="updateValue($event)"
|
||||
:name="`question-${question.id}`"
|
||||
value="yes"
|
||||
:checked="modelValue.value === 'yes'"
|
||||
@change="updateValue('yes')"
|
||||
class="w-4 h-4 text-primary bg-surface border-gray-600 focus:ring-primary focus:ring-offset-surface"
|
||||
:options="availableOptions"
|
||||
class="mb-3"
|
||||
/>
|
||||
<span class="text-white">Yes</span>
|
||||
</label>
|
||||
<label v-if="question.has_no" class="flex items-center gap-2 cursor-pointer">
|
||||
<input
|
||||
type="radio"
|
||||
:name="`question-${question.id}`"
|
||||
value="no"
|
||||
:checked="modelValue.value === 'no'"
|
||||
@change="updateValue('no')"
|
||||
class="w-4 h-4 text-primary bg-surface border-gray-600 focus:ring-primary focus:ring-offset-surface"
|
||||
/>
|
||||
<span class="text-white">No</span>
|
||||
</label>
|
||||
<label v-if="question.has_na" class="flex items-center gap-2 cursor-pointer">
|
||||
<input
|
||||
type="radio"
|
||||
:name="`question-${question.id}`"
|
||||
value="not_applicable"
|
||||
:checked="modelValue.value === 'not_applicable'"
|
||||
@change="updateValue('not_applicable')"
|
||||
class="w-4 h-4 text-primary bg-surface border-gray-600 focus:ring-primary focus:ring-offset-surface"
|
||||
/>
|
||||
<span class="text-white">N/A</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Details textarea (conditional) -->
|
||||
<Transition
|
||||
enter-active-class="transition-all duration-300 ease-out"
|
||||
enter-from-class="opacity-0 -translate-y-1 max-h-0"
|
||||
enter-to-class="opacity-100 translate-y-0 max-h-40"
|
||||
leave-active-class="transition-all duration-200 ease-in"
|
||||
leave-from-class="opacity-100 translate-y-0 max-h-40"
|
||||
leave-to-class="opacity-0 -translate-y-1 max-h-0"
|
||||
>
|
||||
<div v-if="showDetails" class="mt-2">
|
||||
<label class="block text-sm text-gray-400 mb-1">
|
||||
Details{{ detailsRequired ? ' (required)' : ' (optional)' }}
|
||||
@@ -110,10 +106,25 @@ const updateTextValue = (event) => {
|
||||
:value="modelValue.text_value"
|
||||
@input="updateTextValue"
|
||||
rows="2"
|
||||
class="w-full rounded-lg border border-gray-600 bg-surface px-3 py-2 text-white placeholder-gray-500 focus:border-primary focus:ring-1 focus:ring-primary text-sm"
|
||||
class="w-full rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-white placeholder-gray-600 focus:border-primary/50 focus:ring-1 focus:ring-primary/20 text-sm transition-colors duration-200"
|
||||
placeholder="Enter details..."
|
||||
></textarea>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
|
||||
<!-- Error message -->
|
||||
<Transition
|
||||
enter-active-class="transition-all duration-200 ease-out"
|
||||
enter-from-class="opacity-0 -translate-y-1"
|
||||
enter-to-class="opacity-100 translate-y-0"
|
||||
leave-active-class="transition-all duration-150 ease-in"
|
||||
leave-from-class="opacity-100 translate-y-0"
|
||||
leave-to-class="opacity-0 -translate-y-1"
|
||||
>
|
||||
<p v-if="error" class="text-red-400 text-sm mt-2 bg-red-500/10 px-3 py-2 rounded-md">
|
||||
{{ error }}
|
||||
</p>
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
93
resources/js/Components/RadioButtonGroup.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const handleChange = (value) => {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
|
||||
const getSegmentClasses = (index) => {
|
||||
const classes = [
|
||||
'inline-flex',
|
||||
'items-center',
|
||||
'justify-center',
|
||||
'px-8',
|
||||
'py-3',
|
||||
'text-base',
|
||||
'font-medium',
|
||||
'select-none',
|
||||
'transition-all',
|
||||
'duration-200',
|
||||
'bg-white/5',
|
||||
'text-gray-400',
|
||||
'cursor-pointer',
|
||||
'hover:bg-white/10',
|
||||
'hover:text-gray-200',
|
||||
'peer-checked:hover:bg-primary-dark',
|
||||
'peer-checked:hover:text-gray-900',
|
||||
'peer-checked:bg-primary',
|
||||
'peer-checked:text-gray-900',
|
||||
'peer-checked:font-semibold',
|
||||
'peer-focus-visible:ring-2',
|
||||
'peer-focus-visible:ring-primary',
|
||||
'peer-focus-visible:ring-offset-2',
|
||||
'peer-focus-visible:ring-offset-surface',
|
||||
]
|
||||
|
||||
// All except last: add divider
|
||||
if (index < props.options.length - 1) {
|
||||
classes.push('border-r', 'border-white/10')
|
||||
}
|
||||
|
||||
// Disabled state
|
||||
if (props.disabled) {
|
||||
classes.push('disabled:opacity-50', 'disabled:cursor-not-allowed')
|
||||
}
|
||||
|
||||
return classes.join(' ')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div role="radiogroup" :aria-label="name" class="inline-flex rounded-lg overflow-hidden border border-white/10 min-h-[44px]">
|
||||
<label
|
||||
v-for="(option, index) in options"
|
||||
:key="option.value"
|
||||
class="relative"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
:name="name"
|
||||
:value="option.value"
|
||||
:checked="modelValue === option.value"
|
||||
:disabled="disabled"
|
||||
:data-cy="option.value === 'not_applicable' ? 'na' : option.value"
|
||||
@change="handleChange(option.value)"
|
||||
class="sr-only peer"
|
||||
/>
|
||||
<span :class="getSegmentClasses(index)">
|
||||
{{ option.label }}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
@@ -43,20 +43,33 @@ const scoreData = computed(() => {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const panelBorderClass = computed(() => {
|
||||
if (props.score >= 10) return 'border-green-500/20'
|
||||
if (props.score >= 5) return 'border-amber-500/20'
|
||||
if (props.score >= 1) return 'border-red-500/20'
|
||||
return 'border-white/10'
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="inline-flex items-center gap-3">
|
||||
<div
|
||||
v-if="visible"
|
||||
class="inline-flex items-center gap-3 bg-white/5 backdrop-blur-sm border rounded-xl px-5 py-3 transition-all duration-500"
|
||||
:class="panelBorderClass"
|
||||
>
|
||||
<div class="flex items-baseline gap-2">
|
||||
<span class="text-4xl font-bold" :class="scoreData.textClass">
|
||||
<span class="text-3xl font-bold" :class="scoreData.textClass">
|
||||
{{ score }}
|
||||
</span>
|
||||
<span class="text-sm text-gray-400">points</span>
|
||||
<span class="text-xs uppercase tracking-wider text-gray-500">
|
||||
points
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
:class="[
|
||||
scoreData.bgClass,
|
||||
'px-4 py-2 rounded-lg text-white font-semibold text-sm',
|
||||
'px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider text-white shadow-sm',
|
||||
]"
|
||||
>
|
||||
{{ scoreData.label }}
|
||||
|
||||