diff --git a/app/Http/Controllers/Landlord/TenantController.php b/app/Http/Controllers/Landlord/TenantController.php
index 388cefc..6137b77 100644
--- a/app/Http/Controllers/Landlord/TenantController.php
+++ b/app/Http/Controllers/Landlord/TenantController.php
@@ -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'],
]);
diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php
index 5960858..ca4217e 100644
--- a/app/Http/Middleware/HandleInertiaRequests.php
+++ b/app/Http/Middleware/HandleInertiaRequests.php
@@ -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;
},
];
}
diff --git a/resources/js/Layouts/AuthenticatedLayout.tsx b/resources/js/Layouts/AuthenticatedLayout.tsx
index 6036bbd..039d081 100644
--- a/resources/js/Layouts/AuthenticatedLayout.tsx
+++ b/resources/js/Layouts/AuthenticatedLayout.tsx
@@ -454,7 +454,7 @@ export default function AuthenticatedLayout({
- © 2026 小小冰室. All rights reserved. + © {new Date().getFullYear()} {props.branding?.name || '小小冰室'}. All rights reserved.
diff --git a/resources/js/Pages/Landlord/Tenant/Create.tsx b/resources/js/Pages/Landlord/Tenant/Create.tsx index 47277b3..25f68a8 100644 --- a/resources/js/Pages/Landlord/Tenant/Create.tsx +++ b/resources/js/Pages/Landlord/Tenant/Create.tsx @@ -6,6 +6,7 @@ export default function TenantCreate() { const { data, setData, post, processing, errors } = useForm({ id: "", name: "", + short_name: "", email: "", domain: "", }); @@ -55,6 +56,21 @@ export default function TenantCreate() { {errors.name &&{errors.name}
} +選填
+ {errors.short_name &&{errors.short_name}
} +選填
+