Feature: Tenant Short Name and Branding Implementation
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 49s

- Added short_name to Tenant model and controller
- Updated Landlord/Tenant pages (Create, Edit, Show, Index)
- Implemented branding customization (Favicon, Login Copyright, Sidebar Title)
- Updated HandleInertiaRequests to share branding data
This commit is contained in:
2026-01-29 16:28:34 +08:00
parent 746eeb6f01
commit 2e71a1cb29
10 changed files with 78 additions and 18 deletions

View File

@@ -19,6 +19,7 @@ class TenantController extends Controller
return [
'id' => $tenant->id,
'name' => $tenant->name ?? $tenant->id,
'short_name' => $tenant->short_name ?? null,
'email' => $tenant->email ?? null,
'is_active' => $tenant->is_active ?? true,
'created_at' => $tenant->created_at->format('Y-m-d H:i'),
@@ -47,6 +48,7 @@ class TenantController extends Controller
$validated = $request->validate([
'id' => ['required', 'string', 'max:50', 'alpha_dash', Rule::unique('tenants', 'id')],
'name' => ['required', 'string', 'max:100'],
'short_name' => ['nullable', 'string', 'max:50'],
'email' => ['nullable', 'email', 'max:100'],
'domain' => ['nullable', 'string', 'max:100'],
]);
@@ -54,6 +56,7 @@ class TenantController extends Controller
$tenant = Tenant::create([
'id' => $validated['id'],
'name' => $validated['name'],
'short_name' => $validated['short_name'] ?? null,
'email' => $validated['email'] ?? null,
'is_active' => true,
'branding' => [
@@ -85,6 +88,7 @@ class TenantController extends Controller
'tenant' => [
'id' => $tenant->id,
'name' => $tenant->name ?? $tenant->id,
'short_name' => $tenant->short_name ?? null,
'email' => $tenant->email ?? null,
'is_active' => $tenant->is_active ?? true,
'created_at' => $tenant->created_at->format('Y-m-d H:i'),
@@ -128,6 +132,7 @@ class TenantController extends Controller
'tenant' => [
'id' => $tenant->id,
'name' => $tenant->name ?? $tenant->id,
'short_name' => $tenant->short_name ?? null,
'email' => $tenant->email ?? null,
'is_active' => $tenant->is_active ?? true,
],
@@ -143,6 +148,7 @@ class TenantController extends Controller
$validated = $request->validate([
'name' => ['required', 'string', 'max:100'],
'short_name' => ['nullable', 'string', 'max:50'],
'email' => ['nullable', 'email', 'max:100'],
'is_active' => ['boolean'],
]);

View File

@@ -64,25 +64,30 @@ class HandleInertiaRequests extends Middleware
],
'branding' => function () {
$tenant = tenancy()->tenant;
if (!$tenant) {
// 中央後台預設 Branding
return [
'logo_url' => \Storage::url('defaults/logo.png'), // 中央後台也使用預設 Logo
'primary_color' => '#4F46E5',
'text_color' => '#1a1a1a',
];
}
// 決定名稱顯示邏輯
$fullName = $tenant ? ($tenant->name ?? 'Star ERP') : 'Star ERP 中央後台';
$shortName = $tenant ? ($tenant->short_name ?? $fullName) : 'Start ERP';
$logoUrl = null;
if (isset($tenant->branding['logo_path'])) {
if ($tenant && isset($tenant->branding['logo_path'])) {
$logoUrl = \Storage::url($tenant->branding['logo_path']);
} elseif (!$tenant) {
$logoUrl = \Storage::url('defaults/logo.png');
}
return [
$brandingData = [
'name' => $fullName,
'short_name' => $shortName,
'logo_url' => $logoUrl,
'primary_color' => $tenant->branding['primary_color'] ?? '#01ab83',
'primary_color' => $tenant->branding['primary_color'] ?? ($tenant ? '#01ab83' : '#4F46E5'),
'text_color' => $tenant->branding['text_color'] ?? '#1a1a1a',
];
// 同步分享給 Blade View (給 app.blade.php 使用 Favicon)
\Illuminate\Support\Facades\View::share('branding', $brandingData);
return $brandingData;
},
];
}