Skip to content

Commit 95fb402

Browse files
committed
refactor: rename "Main" organization to "Default" across codebase
"Default" better communicates the role of the primary organization — it is the fallback context, not necessarily the most important one. Renames: is_main → is_default column, Organization::main() → Organization::default(), factory state main() → default(), and all references in app code, migrations, factories, seeders, tests, and docs.
1 parent f22557a commit 95fb402

31 files changed

Lines changed: 109 additions & 109 deletions

app/Actions/Fortify/CreateNewUser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public function create(array $input): User
4848

4949
$createDemoBackup = ! empty($input['create_demo_backup']);
5050

51-
// Ensure main org exists (migration creates it, but handle fresh install)
52-
$mainOrg = Organization::firstOrCreate(
53-
['is_main' => true],
54-
['name' => 'Main']
51+
// Ensure default org exists (migration creates it, but handle fresh install)
52+
$defaultOrg = Organization::firstOrCreate(
53+
['is_default' => true],
54+
['name' => 'Default']
5555
);
5656

5757
// First user is always super_admin
@@ -64,7 +64,7 @@ public function create(array $input): User
6464
]);
6565

6666
// Attach to main org as admin
67-
$user->organizations()->attach($mainOrg->id, ['role' => UserRole::Admin->value]);
67+
$user->organizations()->attach($defaultOrg->id, ['role' => UserRole::Admin->value]);
6868

6969
if ($createDemoBackup) {
7070
try {

app/Http/Middleware/DemoModeMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function ensureDemoUserExists(): void
6464
);
6565

6666
$user->organizations()->syncWithoutDetaching([
67-
Organization::main()->id => ['role' => UserRole::Demo->value],
67+
Organization::default()->id => ['role' => UserRole::Demo->value],
6868
]);
6969
}
7070
}

app/Http/Resources/OrganizationResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function toArray(Request $request): array
2121
return [
2222
'id' => $this->id,
2323
'name' => $this->name,
24-
'is_main' => $this->is_main,
24+
'is_default' => $this->is_default,
2525
'role' => $this->whenPivotLoaded('organization_user', fn () => $this->pivot->role), // @phpstan-ignore property.notFound
2626
];
2727
}

app/Livewire/Configuration/Organization.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function organizations(): Collection
5151
'volumes' => fn ($q) => $q->withoutGlobalScope(OrganizationScope::class),
5252
'agents' => fn ($q) => $q->withoutGlobalScope(OrganizationScope::class),
5353
])
54-
->orderByDesc('is_main')
54+
->orderByDesc('is_default')
5555
->orderBy('name')
5656
->get();
5757
}

app/Livewire/OrganizationSwitcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public function getOrganizations(): array
3939
$user = auth()->user();
4040

4141
if ($user->isSuperAdmin()) {
42-
return Organization::orderByDesc('is_main')->orderBy('name')->get(['id', 'name'])->toArray();
42+
return Organization::orderByDesc('is_default')->orderBy('name')->get(['id', 'name'])->toArray();
4343
}
4444

45-
return $user->organizations()->orderByDesc('organizations.is_main')->orderBy('organizations.name')->get(['organizations.id', 'organizations.name'])->toArray();
45+
return $user->organizations()->orderByDesc('organizations.is_default')->orderBy('organizations.name')->get(['organizations.id', 'organizations.name'])->toArray();
4646
}
4747

4848
public function render(): View

app/Mcp/Tools/ListOrganizationsTool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function handle(Request $request): Response
3131
$active = $org->id === $currentOrgId ? ' **(active)**' : '';
3232
$role = $org->pivot->role ?? 'unknown';
3333

34-
return "- **{$org->name}** (ID: {$org->id}){$active}\n Role: {$role}".($org->is_main ? ' | Main organization' : '');
34+
return "- **{$org->name}** (ID: {$org->id}){$active}\n Role: {$role}".($org->is_default ? ' | Default organization' : '');
3535
});
3636

3737
return Response::text("Your Organizations ({$orgs->count()}):\n\n".implode("\n\n", $lines->all()));

app/Models/Organization.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* @property string $id
1818
* @property string $name
19-
* @property bool $is_main
19+
* @property bool $is_default
2020
* @property Carbon|null $created_at
2121
* @property Carbon|null $updated_at
2222
* @property-read Collection<int, User> $users
@@ -44,13 +44,13 @@ class Organization extends Model
4444

4545
protected $fillable = [
4646
'name',
47-
'is_main',
47+
'is_default',
4848
];
4949

5050
protected function casts(): array
5151
{
5252
return [
53-
'is_main' => 'boolean',
53+
'is_default' => 'boolean',
5454
];
5555
}
5656

@@ -95,11 +95,11 @@ public function sshConfigs(): HasMany
9595
}
9696

9797
/**
98-
* Get the main organization.
98+
* Get the default organization.
9999
*/
100-
public static function main(): self
100+
public static function default(): self
101101
{
102-
return static::where('is_main', true)->firstOrFail();
102+
return static::where('is_default', true)->firstOrFail();
103103
}
104104

105105
/**

app/Policies/OrganizationPolicy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ public function update(User $user, Organization $organization): bool
3434
return false;
3535
}
3636

37-
// Main org name cannot be changed
38-
return ! $organization->is_main;
37+
// Default org name cannot be changed
38+
return ! $organization->is_default;
3939
}
4040

4141
/**
4242
* Determine whether the user can delete the organization.
43-
* Only super admins can delete non-main orgs.
43+
* Only super admins can delete non-default orgs.
4444
*/
4545
public function delete(User $user, Organization $organization): bool
4646
{
4747
if (! $user->isSuperAdmin()) {
4848
return false;
4949
}
5050

51-
return ! $organization->is_main;
51+
return ! $organization->is_default;
5252
}
5353
}

app/Services/CurrentOrganization.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ public function resolveForUser(User $user, ?string $cookieOrgId = null): void
115115
return;
116116
}
117117

118-
// 3. Super admins with no membership fall back to main org
118+
// 3. Super admins with no membership fall back to default org
119119
if ($user->isSuperAdmin()) {
120-
$this->switchTo(Organization::main());
120+
$this->switchTo(Organization::default());
121121

122122
return;
123123
}

app/Services/OAuthService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private function resolveDefaultOrganization(): Organization
219219
}
220220
}
221221

222-
return Organization::main();
222+
return Organization::default();
223223
}
224224

225225
/**

0 commit comments

Comments
 (0)