Add industry packages that provision workflow stages on onboarding.
Deploy Ladill Queue / deploy (push) Successful in 1m39s
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user