Commit 6079ab5d authored by Mahmoud Aglan's avatar Mahmoud Aglan

Remove academy creation from setup wizard — academy comes from env vars

The academy identity is now established by the seeder (from ACADEMY_NAME_EN,
ACADEMY_NAME_AR env vars). The wizard no longer has an "Academy Profile" step.
It starts directly at Branches (step 1) and only configures operational data:
branches, activities, programs, facilities, groups, staff, settings.

This enforces one-academy-per-instance: the academy exists before the wizard
runs, and no user action can create or duplicate it.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 2f4c631c
...@@ -30,40 +30,30 @@ ...@@ -30,40 +30,30 @@
class SetupWizard extends Component class SetupWizard extends Component
{ {
public int $currentStep = 1; public int $currentStep = 1;
public int $totalSteps = 12; public int $totalSteps = 11;
// Step 1: Academy Profile // Step 1: Branches
public string $academyName = '';
public string $academyNameAr = '';
public string $academyPhone = '';
public string $academyEmail = '';
public string $academyAddress = '';
public string $academyType = '';
public string $academyWebsite = '';
public string $socialWhatsapp = '';
// Step 2: Branches
public array $branches = []; public array $branches = [];
// Step 3: Activities // Step 2: Activities
public array $activities = []; public array $activities = [];
// Step 4: Programs // Step 3: Programs
public array $programs = []; public array $programs = [];
// Step 5: Facilities + Grid // Step 4: Facilities + Grid
public array $facilities = []; public array $facilities = [];
// Step 6: Groups + Schedule // Step 5: Groups + Schedule
public array $groups = []; public array $groups = [];
// Step 7: Participants // Step 6: Participants
public array $participants = []; public array $participants = [];
// Step 8: Staff & Users // Step 7: Staff & Users
public array $users = []; public array $users = [];
// Step 9: Financial & Pricing // Step 8: Financial & Pricing
public bool $taxEnabled = false; public bool $taxEnabled = false;
public float $taxPercentage = 14; public float $taxPercentage = 14;
public string $invoicePrefix = 'INV'; public string $invoicePrefix = 'INV';
...@@ -76,7 +66,7 @@ class SetupWizard extends Component ...@@ -76,7 +66,7 @@ class SetupWizard extends Component
public int $familyDiscountStartChild = 2; public int $familyDiscountStartChild = 2;
public int $trialPeriodDays = 7; public int $trialPeriodDays = 7;
// Step 10: Rules & Policies // Step 9: Rules & Policies
public int $gracePeriodParticipant = 15; public int $gracePeriodParticipant = 15;
public int $gracePeriodTrainer = 10; public int $gracePeriodTrainer = 10;
public int $autoAbsentAfterHours = 2; public int $autoAbsentAfterHours = 2;
...@@ -90,7 +80,7 @@ class SetupWizard extends Component ...@@ -90,7 +80,7 @@ class SetupWizard extends Component
public bool $emailEnabled = true; public bool $emailEnabled = true;
public bool $smsEnabled = false; public bool $smsEnabled = false;
// Step 11: General Settings // Step 10: General Settings
public string $defaultCurrency = 'EGP'; public string $defaultCurrency = 'EGP';
public string $timezone = 'Africa/Cairo'; public string $timezone = 'Africa/Cairo';
public string $weekStartsOn = '6'; public string $weekStartsOn = '6';
...@@ -118,10 +108,6 @@ public function mount(): void ...@@ -118,10 +108,6 @@ public function mount(): void
return; return;
} }
// Pre-fill academy info
$this->academyName = $this->academy->name ?? '';
$this->academyNameAr = $this->academy->name_ar ?? '';
// Initialize with one empty branch // Initialize with one empty branch
$this->addBranch(); $this->addBranch();
} }
...@@ -345,33 +331,14 @@ public function removeUser(int $index): void ...@@ -345,33 +331,14 @@ public function removeUser(int $index): void
protected function validateCurrentStep(): void protected function validateCurrentStep(): void
{ {
match ($this->currentStep) { match ($this->currentStep) {
1 => $this->validate([ 1 => $this->validateBranches(),
'academyNameAr' => 'required|string|min:3|max:255', 2 => $this->validateActivities(),
'academyName' => 'nullable|string|max:255', 3 => $this->validatePrograms(),
'academyPhone' => 'required|string|max:20', 4 => $this->validateFacilities(),
'academyEmail' => 'required|email|max:255', 5 => $this->validateGroups(),
'academyAddress' => 'nullable|string|max:500', 6 => $this->validateParticipants(),
'academyType' => 'required|string|in:sports_club,fitness_center,educational_center,multi_sport,swimming_academy,martial_arts,other', 7 => $this->validateUsers(),
'academyWebsite' => 'nullable|url|max:255', 8 => $this->validate([
'socialWhatsapp' => 'nullable|string|max:20',
], [
'academyNameAr.required' => __('اسم الأكاديمية بالعربية مطلوب'),
'academyNameAr.min' => __('اسم الأكاديمية يجب أن يكون 3 أحرف على الأقل'),
'academyPhone.required' => __('رقم هاتف الأكاديمية مطلوب'),
'academyEmail.required' => __('البريد الإلكتروني للأكاديمية مطلوب'),
'academyEmail.email' => __('البريد الإلكتروني غير صالح'),
'academyType.required' => __('نوع الأكاديمية مطلوب'),
'academyType.in' => __('نوع الأكاديمية غير صالح'),
'academyWebsite.url' => __('رابط الموقع غير صالح'),
]),
2 => $this->validateBranches(),
3 => $this->validateActivities(),
4 => $this->validatePrograms(),
5 => $this->validateFacilities(),
6 => $this->validateGroups(),
7 => $this->validateParticipants(),
8 => $this->validateUsers(),
9 => $this->validate([
'taxEnabled' => 'boolean', 'taxEnabled' => 'boolean',
'taxPercentage' => 'required|numeric|min:0|max:100', 'taxPercentage' => 'required|numeric|min:0|max:100',
'invoicePrefix' => 'required|string|max:10', 'invoicePrefix' => 'required|string|max:10',
...@@ -400,7 +367,7 @@ protected function validateCurrentStep(): void ...@@ -400,7 +367,7 @@ protected function validateCurrentStep(): void
'familyDiscountStartChild.required' => __('ترتيب الطفل لبدء خصم العائلة مطلوب'), 'familyDiscountStartChild.required' => __('ترتيب الطفل لبدء خصم العائلة مطلوب'),
'trialPeriodDays.required' => __('فترة التجربة مطلوبة'), 'trialPeriodDays.required' => __('فترة التجربة مطلوبة'),
]), ]),
10 => $this->validate([ 9 => $this->validate([
'gracePeriodParticipant' => 'required|integer|min:0|max:60', 'gracePeriodParticipant' => 'required|integer|min:0|max:60',
'gracePeriodTrainer' => 'required|integer|min:0|max:60', 'gracePeriodTrainer' => 'required|integer|min:0|max:60',
'autoAbsentAfterHours' => 'required|integer|min:1|max:24', 'autoAbsentAfterHours' => 'required|integer|min:1|max:24',
...@@ -427,7 +394,7 @@ protected function validateCurrentStep(): void ...@@ -427,7 +394,7 @@ protected function validateCurrentStep(): void
'freezeMaxDays.required' => __('الحد الأقصى لأيام التجميد مطلوب'), 'freezeMaxDays.required' => __('الحد الأقصى لأيام التجميد مطلوب'),
'freezeMaxDays.min' => __('الحد الأقصى لأيام التجميد يجب أن يكون يوم واحد على الأقل'), 'freezeMaxDays.min' => __('الحد الأقصى لأيام التجميد يجب أن يكون يوم واحد على الأقل'),
]), ]),
11 => $this->validate([ 10 => $this->validate([
'defaultCurrency' => 'required|string|in:EGP,SAR,AED,USD', 'defaultCurrency' => 'required|string|in:EGP,SAR,AED,USD',
'timezone' => 'required|string|timezone', 'timezone' => 'required|string|timezone',
'weekStartsOn' => 'required|string|in:0,1,6', 'weekStartsOn' => 'required|string|in:0,1,6',
...@@ -663,30 +630,13 @@ public function completeSetup(): void ...@@ -663,30 +630,13 @@ public function completeSetup(): void
$academyId = $this->academy->id; $academyId = $this->academy->id;
$actor = auth()->user(); $actor = auth()->user();
// Update academy profile // Update academy currency/timezone from wizard settings
$this->academy->update([ $this->academy->update([
'name' => $this->academyName ?: $this->academyNameAr,
'name_ar' => $this->academyNameAr,
'phone' => $this->academyPhone,
'email' => $this->academyEmail,
'currency' => $this->defaultCurrency, 'currency' => $this->defaultCurrency,
'timezone' => $this->timezone, 'timezone' => $this->timezone,
'settings' => array_merge($this->academy->settings ?? [], [
'address' => $this->academyAddress,
'type' => $this->academyType,
'website' => $this->academyWebsite,
'whatsapp' => $this->socialWhatsapp,
]),
]); ]);
// Save additional academy info as settings
$settingsService = app(SettingsService::class); $settingsService = app(SettingsService::class);
$settingsService->set('academy_phone', $this->academyPhone, 'general', 'string');
$settingsService->set('academy_email', $this->academyEmail, 'general', 'string');
$settingsService->set('academy_address', $this->academyAddress, 'general', 'string');
$settingsService->set('academy_type', $this->academyType, 'general', 'string');
$settingsService->set('academy_website', $this->academyWebsite, 'general', 'string');
$settingsService->set('social_whatsapp', $this->socialWhatsapp, 'general', 'string');
// Create branches // Create branches
$createdBranches = []; $createdBranches = [];
...@@ -1049,31 +999,17 @@ private function generateParticipantNumber(int $academyId, int $index): string ...@@ -1049,31 +999,17 @@ private function generateParticipantNumber(int $academyId, int $index): string
public function getStepLabels(): array public function getStepLabels(): array
{ {
return [ return [
1 => __('الأكاديمية'), 1 => __('الفروع'),
2 => __('الفروع'), 2 => __('الأنشطة'),
3 => __('الأنشطة'), 3 => __('البرامج'),
4 => __('البرامج'), 4 => __('المنشآت'),
5 => __('المنشآت'), 5 => __('المجموعات'),
6 => __('المجموعات'), 6 => __('المشتركين'),
7 => __('المشتركين'), 7 => __('الطاقم'),
8 => __('الطاقم'), 8 => __('المالية'),
9 => __('المالية'), 9 => __('السياسات'),
10 => __('السياسات'), 10 => __('الإعدادات'),
11 => __('الإعدادات'), 11 => __('تم!'),
12 => __('تم!'),
];
}
public function getAcademyTypes(): array
{
return [
'sports_club' => __('نادي رياضي'),
'fitness_center' => __('مركز لياقة'),
'educational_center' => __('مركز تعليمي'),
'multi_sport' => __('أكاديمية متعددة'),
'swimming_academy' => __('أكاديمية سباحة'),
'martial_arts' => __('فنون قتالية'),
'other' => __('أخرى'),
]; ];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment