Add industry packages that provision workflow stages on onboarding.
Deploy Ladill Queue / deploy (push) Successful in 1m39s

Queue Core stays generic; selecting Healthcare, Banking, Restaurant, and other industries installs departments, stages (queues), service points, workflows, terminology, and announcement profiles without code changes per vertical. Care-linked orgs skip stage materialization so Care remains the clinical provisioner.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 18:00:31 +00:00
co-authored by Cursor
parent 0854b431bc
commit a4d8775a82
15 changed files with 2302 additions and 65 deletions
@@ -5,9 +5,10 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\Concerns\ScopesApiToAccount;
use App\Http\Controllers\Controller;
use App\Models\Branch;
use App\Models\Department;
use App\Models\Organization;
use App\Services\Qms\AuditLogger;
use App\Services\Qms\Industry\IndustryPackageInstaller;
use App\Services\Qms\Industry\IndustryPackageRegistry;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
@@ -36,6 +37,8 @@ class IntegrationController extends Controller
'provisioned' => true,
'onboarded' => (bool) data_get($organization->settings, 'onboarded', false),
'organization_name' => $organization->name,
'industry' => data_get($organization->settings, 'industry'),
'industry_package' => data_get($organization->settings, 'industry_package.key'),
'integrations' => [
'care' => (bool) data_get($organization->settings, 'integrations.care_enabled', false),
'frontdesk' => (bool) data_get($organization->settings, 'integrations.frontdesk_enabled', false),
@@ -48,6 +51,7 @@ class IntegrationController extends Controller
{
$owner = $this->ownerRef($request);
$caller = (string) $request->attributes->get('service_caller', '');
$registry = app(IndustryPackageRegistry::class);
$validated = $request->validate([
'organization_name' => ['nullable', 'string', 'max:255'],
@@ -56,8 +60,17 @@ class IntegrationController extends Controller
'industry' => ['nullable', 'string'],
]);
$defaultIndustry = match ($caller) {
'care' => 'healthcare',
'frontdesk' => 'visitor',
'pos' => 'restaurant',
default => 'custom',
};
$industry = $registry->resolveKey($validated['industry'] ?? $defaultIndustry);
$organization = Organization::owned($owner)->first();
$created = false;
$branch = null;
if (! $organization) {
$created = true;
@@ -69,7 +82,7 @@ class IntegrationController extends Controller
'timezone' => $validated['timezone'] ?? config('app.timezone', 'UTC'),
'settings' => [
'onboarded' => true,
'industry' => $validated['industry'] ?? ($caller === 'care' ? 'healthcare' : 'visitor'),
'industry' => $industry,
'appointment_mode' => 'hybrid',
'integrations' => [
'care_enabled' => false,
@@ -85,25 +98,47 @@ class IntegrationController extends Controller
'is_active' => true,
]);
Department::create([
'owner_ref' => $owner,
'branch_id' => $branch->id,
'name' => 'Reception',
'type' => 'reception',
'is_active' => true,
]);
AuditLogger::record($owner, 'organization.created', $organization->id, $owner, Organization::class, $organization->id);
} else {
$branch = Branch::query()
->where('organization_id', $organization->id)
->where('is_active', true)
->orderBy('id')
->first();
if (! $branch) {
$branch = Branch::create([
'owner_ref' => $owner,
'organization_id' => $organization->id,
'name' => $validated['branch_name'] ?? 'Main branch',
'is_active' => true,
]);
}
}
if (in_array($caller, ['care', 'frontdesk'], true)) {
$this->syncIntegrationFlag($organization->fresh(), $caller, true);
$organization = $organization->fresh();
}
// Care owns clinical stage graphs; still apply healthcare terminology/package metadata.
$packageResult = app(IndustryPackageInstaller::class)->install(
$organization->fresh(),
$branch,
$industry,
[
'actor_ref' => $owner,
'skip_stages' => $caller === 'care',
'include_optional' => true,
],
);
return response()->json([
'data' => [
'provisioned' => true,
'organization_name' => $organization->fresh()->name,
'industry' => $industry,
'industry_package' => $packageResult,
'integrations' => [
'care' => (bool) data_get($organization->fresh()->settings, 'integrations.care_enabled', false),
'frontdesk' => (bool) data_get($organization->fresh()->settings, 'integrations.frontdesk_enabled', false),
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Qms;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Qms\Concerns\ScopesToAccount;
use App\Services\Qms\Industry\IndustryPackageRegistry;
use App\Services\Qms\OrganizationResolver;
use App\Support\OrganizationBranding;
use Illuminate\Http\RedirectResponse;
@@ -16,6 +17,7 @@ class OnboardingController extends Controller
public function __construct(
protected OrganizationResolver $organizations,
protected IndustryPackageRegistry $packages,
) {}
public function show(Request $request): View|RedirectResponse
@@ -24,10 +26,18 @@ class OnboardingController extends Controller
return redirect()->route('qms.dashboard');
}
$industries = [];
foreach ($this->packages->all() as $package) {
$industries[$package->key] = [
'label' => $package->label(),
'description' => $package->description(),
];
}
return view('qms.onboarding.show', [
'user' => $request->user(),
'timezones' => timezone_identifiers_list(),
'industries' => config('qms.industry_templates'),
'industries' => $industries,
'appointmentModes' => config('qms.appointment_modes'),
]);
}
@@ -40,7 +50,7 @@ class OnboardingController extends Controller
$validated = $request->validate([
'organization_name' => ['required', 'string', 'max:255'],
'industry' => ['required', 'string', 'in:'.implode(',', array_keys(config('qms.industry_templates')))],
'industry' => ['required', 'string', 'in:'.implode(',', array_keys(config('industry_packages.packages', [])))],
'appointment_mode' => ['required', 'string', 'in:'.implode(',', array_keys(config('qms.appointment_modes')))],
'branch_name' => ['required', 'string', 'max:255'],
'branch_address' => ['nullable', 'string', 'max:500'],
@@ -57,6 +67,11 @@ class OnboardingController extends Controller
]);
}
return redirect()->route('qms.dashboard')->with('success', 'Welcome to Ladill Queue!');
$packageLabel = $this->packages->get($validated['industry'])?->label() ?? 'your industry';
return redirect()->route('qms.dashboard')->with(
'success',
"Welcome to Ladill Queue — {$packageLabel} workflow provisioned."
);
}
}
@@ -6,6 +6,8 @@ use App\Http\Controllers\Controller;
use App\Http\Controllers\Qms\Concerns\ScopesToAccount;
use App\Models\Branch;
use App\Services\Qms\AuditLogger;
use App\Services\Qms\Industry\IndustryPackageInstaller;
use App\Services\Qms\Industry\IndustryPackageRegistry;
use App\Services\Qms\PlanService;
use App\Services\Qms\QmsPermissions;
use App\Support\OrganizationBranding;
@@ -17,7 +19,7 @@ class SettingsController extends Controller
{
use ScopesToAccount;
public function edit(Request $request, PlanService $plans): View
public function edit(Request $request, PlanService $plans, IndustryPackageRegistry $packages): View
{
$this->authorizeAbility($request, 'settings.view');
$organization = $this->organization($request);
@@ -29,12 +31,19 @@ class SettingsController extends Controller
->where('organization_id', $organization->id)
->count();
$packageKey = data_get($organization->settings, 'industry_package.key')
?? data_get($organization->settings, 'industry')
?? 'custom';
$activePackage = $packages->get($packageKey);
return view('qms.settings.edit', [
'organization' => $organization,
'canManage' => $canManage,
'branchCount' => $branchCount,
'appointmentModes' => config('qms.appointment_modes'),
'industries' => config('qms.industry_templates'),
'industries' => $packages->labels(),
'activePackage' => $activePackage,
'packageMeta' => data_get($organization->settings, 'industry_package'),
'hasPaidPlan' => $plans->hasPaidPlan($organization),
'isPro' => $plans->isPro($organization),
'isEnterprise' => $plans->isEnterprise($organization),
@@ -57,7 +66,7 @@ class SettingsController extends Controller
'name' => ['required', 'string', 'max:255'],
'timezone' => ['required', 'timezone'],
'appointment_mode' => ['required', 'string', 'in:'.implode(',', array_keys(config('qms.appointment_modes')))],
'industry' => ['nullable', 'string'],
'industry' => ['nullable', 'string', 'in:'.implode(',', array_keys(config('industry_packages.packages', [])))],
'notifications_enabled' => ['boolean'],
'care_integration_enabled' => ['nullable', 'boolean'],
'frontdesk_integration_enabled' => ['nullable', 'boolean'],
@@ -67,6 +76,7 @@ class SettingsController extends Controller
$settings = $organization->settings ?? [];
$settings['appointment_mode'] = $validated['appointment_mode'];
$previousIndustry = $settings['industry'] ?? null;
$settings['industry'] = $validated['industry'] ?? $settings['industry'] ?? null;
$settings['notifications_enabled'] = $request->boolean('notifications_enabled', true);
$integrations = $settings['integrations'] ?? [];
@@ -98,6 +108,54 @@ class SettingsController extends Controller
AuditLogger::record($owner, 'organization.updated', $organization->id, $owner, \App\Models\Organization::class, $organization->id);
return back()->with('success', 'Settings saved.');
$industryChanged = $settings['industry'] && $settings['industry'] !== $previousIndustry;
if ($industryChanged) {
$branch = Branch::query()
->where('organization_id', $organization->id)
->where('is_active', true)
->orderBy('id')
->first();
if ($branch) {
app(IndustryPackageInstaller::class)->install($organization->fresh(), $branch, $settings['industry'], [
'actor_ref' => $owner,
]);
}
}
return back()->with('success', $industryChanged
? 'Settings saved. Industry package re-provisioned.'
: 'Settings saved.');
}
public function reinstallPackage(Request $request, IndustryPackageInstaller $installer): RedirectResponse
{
$this->authorizeAbility($request, 'settings.manage');
$organization = $this->organization($request);
$owner = $this->ownerRef($request);
$branch = Branch::query()
->where('organization_id', $organization->id)
->where('is_active', true)
->orderBy('id')
->first();
if (! $branch) {
return back()->with('error', 'Add a branch before reinstalling the industry package.');
}
$key = data_get($organization->settings, 'industry', 'custom');
$result = $installer->install($organization, $branch, $key, [
'actor_ref' => $owner,
'include_optional' => true,
]);
$message = 'Industry package synced.';
if (($result['skipped_reason'] ?? null) === 'plan_queue_limit') {
$message .= ' Some stages were skipped because of your plan queue limit — upgrade to Pro for the full template.';
} elseif (($result['skipped_reason'] ?? null) === 'stages_managed_by_integration') {
$message .= ' Stages are managed by Ladill Care; terminology and announcements were updated.';
}
return back()->with('success', $message);
}
}