diff --git a/app/Http/Controllers/Admin/System/GeneralSettingController.php b/app/Http/Controllers/Admin/System/GeneralSettingController.php
index 1a374b0..50ae7c8 100644
--- a/app/Http/Controllers/Admin/System/GeneralSettingController.php
+++ b/app/Http/Controllers/Admin/System/GeneralSettingController.php
@@ -29,12 +29,20 @@ public function update(GeneralSettingRequest $request): RedirectResponse
$setting = GeneralSetting::create($validated);
}
- if ($request->hasFile('logo')) {
- $setting->addMediaFromRequest('logo')->toMediaCollection('logo');
+ if ($request->hasFile('logo_light')) {
+ $setting->addMediaFromRequest('logo_light')->toMediaCollection('logo_light');
}
- if ($request->hasFile('icon')) {
- $setting->addMediaFromRequest('icon')->toMediaCollection('icon');
+ if ($request->hasFile('logo_dark')) {
+ $setting->addMediaFromRequest('logo_dark')->toMediaCollection('logo_dark');
+ }
+
+ if ($request->hasFile('icon_light')) {
+ $setting->addMediaFromRequest('icon_light')->toMediaCollection('icon_light');
+ }
+
+ if ($request->hasFile('icon_dark')) {
+ $setting->addMediaFromRequest('icon_dark')->toMediaCollection('icon_dark');
}
return redirect()->back()->with('success', 'Pengaturan berhasil diperbarui');
diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php
index 77ac6a3..89f6f09 100644
--- a/app/Http/Middleware/HandleInertiaRequests.php
+++ b/app/Http/Middleware/HandleInertiaRequests.php
@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
+use App\Models\GeneralSetting;
use Illuminate\Http\Request;
use Inertia\Middleware;
@@ -38,6 +39,7 @@ public function share(Request $request): array
return [
...parent::share($request),
'name' => config('app.name'),
+ 'setting' => GeneralSetting::first(),
'auth' => [
'user' => $request->user() ? $request->user()->load('profile') : null,
'roles' => $request->user() ? $request->user()->getRoleNames() : [],
diff --git a/app/Http/Requests/Admin/System/GeneralSettingRequest.php b/app/Http/Requests/Admin/System/GeneralSettingRequest.php
index c670ed0..1cd51eb 100644
--- a/app/Http/Requests/Admin/System/GeneralSettingRequest.php
+++ b/app/Http/Requests/Admin/System/GeneralSettingRequest.php
@@ -30,8 +30,10 @@ public function rules(): array
'description' => ['required', 'string'],
'address' => ['required', 'string'],
'phone' => ['required', 'string', 'max:20'],
- 'logo' => [$settingExists ? 'nullable' : 'required', 'image', 'max:2048'],
- 'icon' => [$settingExists ? 'nullable' : 'required', 'image', 'max:1024'],
+ 'logo_light' => [$settingExists ? 'nullable' : 'required', 'image', 'max:2048'],
+ 'logo_dark' => ['nullable', 'image', 'max:2048'],
+ 'icon_light' => [$settingExists ? 'nullable' : 'required', 'image', 'max:1024'],
+ 'icon_dark' => ['nullable', 'image', 'max:1024'],
];
}
}
diff --git a/app/Models/GeneralSetting.php b/app/Models/GeneralSetting.php
index aff5e07..222c0ea 100644
--- a/app/Models/GeneralSetting.php
+++ b/app/Models/GeneralSetting.php
@@ -14,31 +14,51 @@
use Spatie\MediaLibrary\InteractsWithMedia;
#[Guarded(['id'])]
-#[Appends(['logo_url', 'icon_url'])]
+#[Appends(['logo_light_url', 'logo_dark_url', 'icon_light_url', 'icon_dark_url'])]
class GeneralSetting extends Model implements HasMedia
{
use HasFactory, InteractsWithMedia, LogsActivity;
public function registerMediaCollections(): void
{
- $this->addMediaCollection('logo')
+ $this->addMediaCollection('logo_light')
->singleFile();
- $this->addMediaCollection('icon')
+ $this->addMediaCollection('logo_dark')
+ ->singleFile();
+
+ $this->addMediaCollection('icon_light')
+ ->singleFile();
+
+ $this->addMediaCollection('icon_dark')
->singleFile();
}
- protected function logoUrl(): Attribute
+ protected function logoLightUrl(): Attribute
{
return Attribute::make(
- get: fn () => $this->getFirstMediaUrl('logo') ?: null,
+ get: fn () => $this->getFirstMediaUrl('logo_light') ?: null,
);
}
- protected function iconUrl(): Attribute
+ protected function logoDarkUrl(): Attribute
{
return Attribute::make(
- get: fn () => $this->getFirstMediaUrl('icon') ?: null,
+ get: fn () => $this->getFirstMediaUrl('logo_dark') ?: null,
+ );
+ }
+
+ protected function iconLightUrl(): Attribute
+ {
+ return Attribute::make(
+ get: fn () => $this->getFirstMediaUrl('icon_light') ?: null,
+ );
+ }
+
+ protected function iconDarkUrl(): Attribute
+ {
+ return Attribute::make(
+ get: fn () => $this->getFirstMediaUrl('icon_dark') ?: null,
);
}
diff --git a/resources/js/components/app-logo-icon.tsx b/resources/js/components/app-logo-icon.tsx
index 7e9fcf1..f046842 100644
--- a/resources/js/components/app-logo-icon.tsx
+++ b/resources/js/components/app-logo-icon.tsx
@@ -1,3 +1,32 @@
-export default function AppLogoIcon() {
- return
;
+import { cn } from '@/lib/utils';
+import { usePage } from '@inertiajs/react';
+import type { GeneralSetting } from '@/types';
+
+export default function AppLogoIcon({ className }: { className?: string }) {
+ const { setting } = usePage<{ setting: GeneralSetting }>().props;
+
+ if (!setting?.icon_light_url && !setting?.icon_dark_url) {
+ return (
+
+ );
+ }
+
+ return (
+ <>
+ {setting?.icon_light_url && (
+
+ )}
+ {setting?.icon_dark_url && (
+
+ )}
+ >
+ );
}
diff --git a/resources/js/components/app-logo.tsx b/resources/js/components/app-logo.tsx
index 9bac283..845ef14 100644
--- a/resources/js/components/app-logo.tsx
+++ b/resources/js/components/app-logo.tsx
@@ -1,11 +1,30 @@
+import { usePage } from '@inertiajs/react';
+import type { GeneralSetting } from '@/types';
+
export default function AppLogo() {
+ const { setting } = usePage<{ setting: GeneralSetting }>().props;
+
return (
- <>
-