diff --git a/app/Http/Controllers/Qr/QrCodeController.php b/app/Http/Controllers/Qr/QrCodeController.php
index 9170f63..a17ed6a 100644
--- a/app/Http/Controllers/Qr/QrCodeController.php
+++ b/app/Http/Controllers/Qr/QrCodeController.php
@@ -206,6 +206,13 @@ class QrCodeController extends Controller
]);
}
+ $itineraryOptions = $qrCode->type === QrCode::TYPE_EVENT
+ ? $account->qrCodes()
+ ->where('type', QrCode::TYPE_ITINERARY)
+ ->orderBy('label')
+ ->get(['id', 'label'])
+ : collect();
+
return view('qr-codes.show', [
'qrCode' => $qrCode,
'previewDataUri' => $previewDataUri,
@@ -229,6 +236,7 @@ class QrCodeController extends Controller
'customDomains' => \App\Models\CustomDomain::where('qr_code_id', $qrCode->id)->get(),
'customDomainsEnabled' => app(\App\Services\CustomDomain\CustomDomainService::class)->enabled(),
'customDomainServerIp' => config('customdomain.server_ip'),
+ 'itineraryOptions' => $itineraryOptions,
]);
}
diff --git a/resources/views/qr-codes/partials/type-fields-edit.blade.php b/resources/views/qr-codes/partials/type-fields-edit.blade.php
index 2ce4371..2ba9990 100644
--- a/resources/views/qr-codes/partials/type-fields-edit.blade.php
+++ b/resources/views/qr-codes/partials/type-fields-edit.blade.php
@@ -629,7 +629,12 @@
Programme outline (optional)
@if($itineraryOptions->isEmpty())
- Create an Itinerary QR code first to attach it here as the event programme.
+ @if(Route::has('programmes.create'))
+ Create a programme
+ first to attach it here as the event outline.
+ @else
+ Create a programme first to attach it here as the event outline.
+ @endif
@else
diff --git a/tests/Feature/EventProgrammeAttachmentTest.php b/tests/Feature/EventProgrammeAttachmentTest.php
new file mode 100644
index 0000000..188346c
--- /dev/null
+++ b/tests/Feature/EventProgrammeAttachmentTest.php
@@ -0,0 +1,73 @@
+withoutMiddleware(\App\Http\Middleware\EnsurePlatformSession::class);
+ Http::fake([
+ config('billing.api_url').'/balance*' => Http::response(['balance_minor' => 50000]),
+ ]);
+ }
+
+ public function test_event_show_lists_programmes_for_attachment(): void
+ {
+ $owner = User::factory()->create(['public_id' => 'usr_prog_attach']);
+
+ $programme = QrCode::create([
+ 'user_id' => $owner->id,
+ 'short_code' => 'prog-attach-1',
+ 'type' => QrCode::TYPE_ITINERARY,
+ 'label' => 'Summit schedule',
+ 'payload' => ['content' => ['title' => 'Summit schedule'], 'style' => []],
+ 'is_active' => true,
+ ]);
+
+ $event = QrCode::create([
+ 'user_id' => $owner->id,
+ 'short_code' => 'evt-attach-1',
+ 'type' => QrCode::TYPE_EVENT,
+ 'label' => 'Annual summit',
+ 'payload' => ['content' => ['name' => 'Annual summit'], 'style' => []],
+ 'is_active' => true,
+ ]);
+
+ $this->actingAs($owner)
+ ->get(route('events.show', $event))
+ ->assertOk()
+ ->assertSee('name="programme_qr_id"', false)
+ ->assertSee('Summit schedule', false)
+ ->assertDontSee('Create a programme first to attach it here', false);
+ }
+
+ public function test_event_show_prompts_to_create_programme_when_none_exist(): void
+ {
+ $owner = User::factory()->create(['public_id' => 'usr_prog_empty']);
+
+ $event = QrCode::create([
+ 'user_id' => $owner->id,
+ 'short_code' => 'evt-empty-1',
+ 'type' => QrCode::TYPE_EVENT,
+ 'label' => 'Workshop',
+ 'payload' => ['content' => ['name' => 'Workshop'], 'style' => []],
+ 'is_active' => true,
+ ]);
+
+ $this->actingAs($owner)
+ ->get(route('events.show', $event))
+ ->assertOk()
+ ->assertSee('Create a programme', false)
+ ->assertDontSee('name="programme_qr_id"', false);
+ }
+}