From 3fcdaa747579902923ce230f3cda44350d4e3c58 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sat, 2 May 2026 01:05:09 +0700 Subject: [PATCH] refactor: migrate general settings to spatie/laravel-settings and rename properties for consistency --- .../Admin/Manage/OrderController.php | 2 - .../Admin/System/GeneralSettingController.php | 41 +- app/Http/Controllers/HomepageController.php | 2 - app/Http/Middleware/HandleInertiaRequests.php | 2 - .../Admin/System/GeneralSettingRequest.php | 15 +- app/Models/GeneralSetting.php | 111 ----- app/Providers/ViewServiceProvider.php | 75 ++++ app/Settings/GeneralSettings.php | 29 ++ bootstrap/providers.php | 2 + composer.json | 1 + composer.lock | 405 +++++++++++------- ...022_12_14_083707_create_settings_table.php | 24 ++ ...1_000456_create_general_settings_table.php | 31 -- database/seeders/GeneralSettingSeeder.php | 14 +- ...6_05_02_004101_create_general_settings.php | 18 + resources/js/components/app-logo.tsx | 6 +- .../js/pages/admin/manage/order/show.tsx | 12 +- .../js/pages/admin/system/settings/index.tsx | 50 +-- resources/js/pages/homepage.tsx | 20 +- resources/js/types/general-setting.ts | 11 +- resources/views/app.blade.php | 10 +- tests/Feature/Admin/Manage/OrderTest.php | 14 +- .../Admin/System/GeneralSettingTest.php | 54 +-- 23 files changed, 518 insertions(+), 431 deletions(-) delete mode 100644 app/Models/GeneralSetting.php create mode 100644 app/Providers/ViewServiceProvider.php create mode 100644 app/Settings/GeneralSettings.php create mode 100644 database/migrations/2022_12_14_083707_create_settings_table.php delete mode 100644 database/migrations/2026_04_21_000456_create_general_settings_table.php create mode 100644 database/settings/2026_05_02_004101_create_general_settings.php diff --git a/app/Http/Controllers/Admin/Manage/OrderController.php b/app/Http/Controllers/Admin/Manage/OrderController.php index fffeda9..7867e3b 100644 --- a/app/Http/Controllers/Admin/Manage/OrderController.php +++ b/app/Http/Controllers/Admin/Manage/OrderController.php @@ -8,7 +8,6 @@ use App\Enums\PriceType; use App\Http\Controllers\Controller; use App\Http\Requests\Admin\Manage\Order\OrderRequest; -use App\Models\GeneralSetting; use App\Models\Order; use App\Models\OrderItem; use App\Models\Product; @@ -122,7 +121,6 @@ public function show(Order $order): Response return Inertia::render('admin/manage/order/show', [ 'order' => $order, - 'setting' => GeneralSetting::first(), ]); } diff --git a/app/Http/Controllers/Admin/System/GeneralSettingController.php b/app/Http/Controllers/Admin/System/GeneralSettingController.php index 50ae7c8..4afdc79 100644 --- a/app/Http/Controllers/Admin/System/GeneralSettingController.php +++ b/app/Http/Controllers/Admin/System/GeneralSettingController.php @@ -4,8 +4,9 @@ use App\Http\Controllers\Controller; use App\Http\Requests\Admin\System\GeneralSettingRequest; -use App\Models\GeneralSetting; +use App\Settings\GeneralSettings; use Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Storage; use Inertia\Inertia; use Inertia\Response; @@ -13,38 +14,48 @@ class GeneralSettingController extends Controller { public function index(): Response { - return Inertia::render('admin/system/settings/index', [ - 'setting' => GeneralSetting::first(), - ]); + return Inertia::render('admin/system/settings/index'); } - public function update(GeneralSettingRequest $request): RedirectResponse + public function update(GeneralSettingRequest $request, GeneralSettings $settings): RedirectResponse { $validated = $request->validated(); - $setting = GeneralSetting::first(); - if ($setting) { - $setting->update($validated); - } else { - $setting = GeneralSetting::create($validated); - } + $settings->site_name = $validated['site_name']; + $settings->site_description = $validated['site_description']; + $settings->site_address = $validated['site_address']; + $settings->site_phone = $validated['site_phone']; if ($request->hasFile('logo_light')) { - $setting->addMediaFromRequest('logo_light')->toMediaCollection('logo_light'); + if ($settings->logo_light) { + Storage::disk('public')->delete($settings->logo_light); + } + $settings->logo_light = $request->file('logo_light')->store('settings', 'public'); } if ($request->hasFile('logo_dark')) { - $setting->addMediaFromRequest('logo_dark')->toMediaCollection('logo_dark'); + if ($settings->logo_dark) { + Storage::disk('public')->delete($settings->logo_dark); + } + $settings->logo_dark = $request->file('logo_dark')->store('settings', 'public'); } if ($request->hasFile('icon_light')) { - $setting->addMediaFromRequest('icon_light')->toMediaCollection('icon_light'); + if ($settings->icon_light) { + Storage::disk('public')->delete($settings->icon_light); + } + $settings->icon_light = $request->file('icon_light')->store('settings', 'public'); } if ($request->hasFile('icon_dark')) { - $setting->addMediaFromRequest('icon_dark')->toMediaCollection('icon_dark'); + if ($settings->icon_dark) { + Storage::disk('public')->delete($settings->icon_dark); + } + $settings->icon_dark = $request->file('icon_dark')->store('settings', 'public'); } + $settings->save(); + return redirect()->back()->with('success', 'Pengaturan berhasil diperbarui'); } } diff --git a/app/Http/Controllers/HomepageController.php b/app/Http/Controllers/HomepageController.php index 4660532..e911083 100644 --- a/app/Http/Controllers/HomepageController.php +++ b/app/Http/Controllers/HomepageController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use App\Models\Category; -use App\Models\GeneralSetting; use App\Models\Product; class HomepageController extends Controller @@ -14,7 +13,6 @@ public function __invoke() $categorySlug = request('category'); return inertia('homepage', [ - 'setting' => GeneralSetting::first(), 'categories' => Category::active()->get(), 'bestSellers' => Product::with(['categories' => fn ($q) => $q->active(), 'prices']) ->when($search, function ($query, $search) { diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 89f6f09..77ac6a3 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -2,7 +2,6 @@ namespace App\Http\Middleware; -use App\Models\GeneralSetting; use Illuminate\Http\Request; use Inertia\Middleware; @@ -39,7 +38,6 @@ 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 1cd51eb..7c5e0b1 100644 --- a/app/Http/Requests/Admin/System/GeneralSettingRequest.php +++ b/app/Http/Requests/Admin/System/GeneralSettingRequest.php @@ -2,7 +2,6 @@ namespace App\Http\Requests\Admin\System; -use App\Models\GeneralSetting; use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; @@ -23,16 +22,14 @@ public function authorize(): bool */ public function rules(): array { - $settingExists = GeneralSetting::exists(); - return [ - 'name' => ['required', 'string', 'max:50'], - 'description' => ['required', 'string'], - 'address' => ['required', 'string'], - 'phone' => ['required', 'string', 'max:20'], - 'logo_light' => [$settingExists ? 'nullable' : 'required', 'image', 'max:2048'], + 'site_name' => ['required', 'string', 'max:50'], + 'site_description' => ['required', 'string'], + 'site_address' => ['required', 'string'], + 'site_phone' => ['required', 'string', 'max:20'], + 'logo_light' => ['nullable', 'image', 'max:2048'], 'logo_dark' => ['nullable', 'image', 'max:2048'], - 'icon_light' => [$settingExists ? 'nullable' : 'required', 'image', 'max:1024'], + 'icon_light' => ['nullable', 'image', 'max:1024'], 'icon_dark' => ['nullable', 'image', 'max:1024'], ]; } diff --git a/app/Models/GeneralSetting.php b/app/Models/GeneralSetting.php deleted file mode 100644 index 222c0ea..0000000 --- a/app/Models/GeneralSetting.php +++ /dev/null @@ -1,111 +0,0 @@ -addMediaCollection('logo_light') - ->singleFile(); - - $this->addMediaCollection('logo_dark') - ->singleFile(); - - $this->addMediaCollection('icon_light') - ->singleFile(); - - $this->addMediaCollection('icon_dark') - ->singleFile(); - } - - protected function logoLightUrl(): Attribute - { - return Attribute::make( - get: fn () => $this->getFirstMediaUrl('logo_light') ?: null, - ); - } - - protected function logoDarkUrl(): Attribute - { - return Attribute::make( - 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, - ); - } - - public function getActivitylogOptions(): LogOptions - { - return LogOptions::defaults() - ->logOnly(['name', 'description', 'address', 'phone']) - ->logOnlyDirty() - ->useLogName('Pengaturan Umum'); - } - - public function tapActivity(Activity $activity, string $eventName) - { - $activity->description = match ($eventName) { - 'created' => 'TAMBAH', - 'updated' => 'UBAH', - 'deleted' => 'HAPUS', - default => $activity->description, - }; - - if (isset($activity->properties['attributes'])) { - $attributeMap = [ - 'name' => 'Nama Aplikasi', - 'description' => 'Deskripsi', - 'address' => 'Alamat', - 'phone' => 'No. Telepon', - ]; - - $properties = $activity->properties->toArray(); - - $localizeValues = function ($attrs) use ($attributeMap) { - $newAttrs = []; - foreach ($attrs as $key => $value) { - $label = $attributeMap[$key] ?? $key; - $newAttrs[$label] = $value; - } - - return $newAttrs; - }; - - $properties['attributes'] = $localizeValues($properties['attributes']); - - if (isset($properties['old'])) { - $properties['old'] = $localizeValues($properties['old']); - } - - $activity->properties = collect($properties); - } - } -} diff --git a/app/Providers/ViewServiceProvider.php b/app/Providers/ViewServiceProvider.php new file mode 100644 index 0000000..1d8c76f --- /dev/null +++ b/app/Providers/ViewServiceProvider.php @@ -0,0 +1,75 @@ +app->runningInConsole() && ! $this->app->environment('testing')) { + return; + } + + // Share settings with Inertia + Inertia::share('setting', function () { + try { + $settings = app(GeneralSettings::class); + + return [ + 'site_name' => $settings->site_name, + 'site_description' => $settings->site_description, + 'site_address' => $settings->site_address, + 'site_phone' => $settings->site_phone, + 'logo_light_url' => $settings->logo_light ? Storage::url($settings->logo_light) : null, + 'logo_dark_url' => $settings->logo_dark ? Storage::url($settings->logo_dark) : null, + 'icon_light_url' => $settings->icon_light ? Storage::url($settings->icon_light) : null, + 'icon_dark_url' => $settings->icon_dark ? Storage::url($settings->icon_dark) : null, + ]; + } catch (\Exception $e) { + return []; + } + }); + + // Share settings with Blade views + View::composer('*', function ($view) { + try { + $settings = app(GeneralSettings::class); + $view->with('setting', [ + 'site_name' => $settings->site_name, + 'site_description' => $settings->site_description, + 'site_address' => $settings->site_address, + 'site_phone' => $settings->site_phone, + 'logo_light_url' => $settings->logo_light ? Storage::url($settings->logo_light) : null, + 'logo_dark_url' => $settings->logo_dark ? Storage::url($settings->logo_dark) : null, + 'icon_light_url' => $settings->icon_light ? Storage::url($settings->icon_light) : null, + 'icon_dark_url' => $settings->icon_dark ? Storage::url($settings->icon_dark) : null, + ]); + } catch (\Exception $e) { + $view->with('setting', []); + } + }); + } +} diff --git a/app/Settings/GeneralSettings.php b/app/Settings/GeneralSettings.php new file mode 100644 index 0000000..07e5979 --- /dev/null +++ b/app/Settings/GeneralSettings.php @@ -0,0 +1,29 @@ +=14" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^12 || ^14", + "phpstan/phpstan": "1.4.10 || 2.1.30", + "phpstan/phpstan-phpunit": "^1.0 || ^2", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12.4 || ^13.0", + "psr/log": "^1 || ^2 || ^3" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/1.1.6" + }, + "time": "2026-02-07T07:09:04+00:00" + }, { "name": "doctrine/inflector", "version": "2.1.0", @@ -3976,6 +4024,117 @@ }, "time": "2025-09-24T15:06:41+00:00" }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "327a05bbee54120d4786a0dc67aad30226ad4cf9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/327a05bbee54120d4786a0dc67aad30226ad4cf9", + "reference": "327a05bbee54120d4786a0dc67aad30226ad4cf9", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.0", + "php": "^7.4 || ^8.0", + "phpdocumentor/reflection-common": "^2.0", + "phpstan/phpdoc-parser": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "psalm/phar": "^4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev", + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/2.0.0" + }, + "time": "2026-01-06T21:53:42+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.5", @@ -5316,6 +5475,91 @@ ], "time": "2026-04-07T15:19:42+00:00" }, + { + "name": "spatie/laravel-settings", + "version": "3.8.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-settings.git", + "reference": "09b788ee96d205699420dedb8a6aa8c4c8af84fe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-settings/zipball/09b788ee96d205699420dedb8a6aa8c4c8af84fe", + "reference": "09b788ee96d205699420dedb8a6aa8c4c8af84fe", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/database": "^11.0|^12.0|^13.0", + "php": "^8.2", + "phpdocumentor/type-resolver": "^1.5|^2.0", + "spatie/temporary-directory": "^1.3|^2.0" + }, + "require-dev": { + "ext-redis": "*", + "mockery/mockery": "^1.4", + "orchestra/testbench": "^9.0|^10.0|^11.0", + "pestphp/pest": "^2.0|^3.0|^4.0", + "pestphp/pest-plugin-laravel": "^2.0|^3.0|^4.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "spatie/laravel-data": "^2.0.0|^4.0.0", + "spatie/pest-plugin-snapshots": "^2.0", + "spatie/phpunit-snapshot-assertions": "^4.2|^5.0", + "spatie/ray": "^1.36" + }, + "suggest": { + "spatie/data-transfer-object": "Allows for DTO casting to settings. (deprecated)" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\LaravelSettings\\LaravelSettingsServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Spatie\\LaravelSettings\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ruben Van Assche", + "email": "ruben@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Store your application settings", + "homepage": "https://github.com/spatie/laravel-settings", + "keywords": [ + "laravel-settings", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-settings/issues", + "source": "https://github.com/spatie/laravel-settings/tree/3.8.0" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2026-04-28T07:05:06+00:00" + }, { "name": "spatie/laravel-sluggable", "version": "3.8.1", @@ -8245,54 +8489,6 @@ ], "time": "2026-03-29T15:46:14+00:00" }, - { - "name": "doctrine/deprecations", - "version": "1.1.6", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca", - "reference": "d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "conflict": { - "phpunit/phpunit": "<=7.5 || >=14" - }, - "require-dev": { - "doctrine/coding-standard": "^9 || ^12 || ^14", - "phpstan/phpstan": "1.4.10 || 2.1.30", - "phpstan/phpstan-phpunit": "^1.0 || ^2", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12.4 || ^13.0", - "psr/log": "^1 || ^2 || ^3" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.6" - }, - "time": "2026-02-07T07:09:04+00:00" - }, { "name": "fakerphp/faker", "version": "v1.24.1", @@ -9630,59 +9826,6 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, { "name": "phpdocumentor/reflection-docblock", "version": "6.0.3", @@ -9748,64 +9891,6 @@ }, "time": "2026-03-18T20:49:53+00:00" }, - { - "name": "phpdocumentor/type-resolver", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "327a05bbee54120d4786a0dc67aad30226ad4cf9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/327a05bbee54120d4786a0dc67aad30226ad4cf9", - "reference": "327a05bbee54120d4786a0dc67aad30226ad4cf9", - "shasum": "" - }, - "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "phpbench/phpbench": "^1.2", - "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.1", - "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^9.5", - "psalm/phar": "^4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev", - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/2.0.0" - }, - "time": "2026-01-06T21:53:42+00:00" - }, { "name": "phpunit/php-code-coverage", "version": "12.5.6", diff --git a/database/migrations/2022_12_14_083707_create_settings_table.php b/database/migrations/2022_12_14_083707_create_settings_table.php new file mode 100644 index 0000000..dd0be6f --- /dev/null +++ b/database/migrations/2022_12_14_083707_create_settings_table.php @@ -0,0 +1,24 @@ +id(); + + $table->string('group'); + $table->string('name'); + $table->boolean('locked')->default(false); + $table->json('payload'); + + $table->timestamps(); + + $table->unique(['group', 'name']); + }); + } +}; diff --git a/database/migrations/2026_04_21_000456_create_general_settings_table.php b/database/migrations/2026_04_21_000456_create_general_settings_table.php deleted file mode 100644 index d4a8c62..0000000 --- a/database/migrations/2026_04_21_000456_create_general_settings_table.php +++ /dev/null @@ -1,31 +0,0 @@ -id(); - $table->string('name', 50); - $table->text('description'); - $table->text('address'); - $table->string('phone', 20); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('general_settings'); - } -}; diff --git a/database/seeders/GeneralSettingSeeder.php b/database/seeders/GeneralSettingSeeder.php index 076012a..87cf566 100644 --- a/database/seeders/GeneralSettingSeeder.php +++ b/database/seeders/GeneralSettingSeeder.php @@ -2,7 +2,7 @@ namespace Database\Seeders; -use App\Models\GeneralSetting; +use App\Settings\GeneralSettings; use Illuminate\Database\Seeder; class GeneralSettingSeeder extends Seeder @@ -12,11 +12,11 @@ class GeneralSettingSeeder extends Seeder */ public function run(): void { - GeneralSetting::updateOrCreate([ - 'name' => 'VN Grup', - 'description' => 'VN Grup adalah Toko Baju Daster Online yang menghadirkan koleksi baju daster berkualitas tinggi untuk wanita yang mengutamakan kenyamanan tanpa mengorbankan gaya. Kami menyediakan berbagai macam daster dengan desain yang beragam, mulai dari yang sederhana dan klasik hingga yang modern dan trendi, cocok untuk berbagai kebutuhan, baik di rumah maupun saat bersantai di luar.', - 'address' => 'Jl. Raya Pabuaran-Cipeunduy, Kec. Pabuaran, Kab. Subang, Jawa Barat', - 'phone' => '089679965828', - ]); + $settings = app(GeneralSettings::class); + $settings->site_name = 'VN Grup'; + $settings->site_description = 'VN Grup adalah Toko Baju Daster Online yang menghadirkan koleksi baju daster berkualitas tinggi untuk wanita yang mengutamakan kenyamanan tanpa mengorbankan gaya. Kami menyediakan berbagai macam daster dengan desain yang beragam, mulai dari yang sederhana dan klasik hingga yang modern dan trendi, cocok untuk berbagai kebutuhan, baik di rumah maupun saat bersantai di luar.'; + $settings->site_address = 'Jl. Raya Pabuaran-Cipeunduy, Kec. Pabuaran, Kab. Subang, Jawa Barat'; + $settings->site_phone = '089679965828'; + $settings->save(); } } diff --git a/database/settings/2026_05_02_004101_create_general_settings.php b/database/settings/2026_05_02_004101_create_general_settings.php new file mode 100644 index 0000000..8baf209 --- /dev/null +++ b/database/settings/2026_05_02_004101_create_general_settings.php @@ -0,0 +1,18 @@ +migrator->add('general.site_name', 'VN Grup'); + $this->migrator->add('general.site_description', 'VN Grup adalah Toko Baju Daster Online yang menghadirkan koleksi baju daster berkualitas tinggi untuk wanita yang mengutamakan kenyamanan tanpa mengorbankan gaya.'); + $this->migrator->add('general.site_address', 'Jl. Raya Pabuaran-Cipeunduy, Kec. Pabuaran, Kab. Subang, Jawa Barat'); + $this->migrator->add('general.site_phone', '089679965828'); + $this->migrator->add('general.logo_light', null); + $this->migrator->add('general.logo_dark', null); + $this->migrator->add('general.icon_light', null); + $this->migrator->add('general.icon_dark', null); + } +}; diff --git a/resources/js/components/app-logo.tsx b/resources/js/components/app-logo.tsx index 845ef14..bf1b0ff 100644 --- a/resources/js/components/app-logo.tsx +++ b/resources/js/components/app-logo.tsx @@ -9,20 +9,20 @@ export default function AppLogo() { {setting?.logo_light_url ? ( {setting.name} ) : null} {setting?.logo_dark_url ? ( {setting.name} ) : null} {!setting?.logo_light_url && !setting?.logo_dark_url && ( - {setting?.name || 'VN Grup'} + {setting?.site_name || 'VN Grup'} )} diff --git a/resources/js/pages/admin/manage/order/show.tsx b/resources/js/pages/admin/manage/order/show.tsx index d2d3247..15851e4 100644 --- a/resources/js/pages/admin/manage/order/show.tsx +++ b/resources/js/pages/admin/manage/order/show.tsx @@ -62,17 +62,17 @@ export default function OrderShow({ order, setting }: ShowProps) { Logo ) : (
- {setting?.name?.charAt(0) || 'V'} + {setting?.site_name?.charAt(0) || 'V'}
)}
-

{setting?.name || 'VN Grup'}

+

{setting?.site_name || 'VN Grup'}

Your Style, Our Passion

-

{setting?.address || 'Alamat Toko Belum Diatur'}

-

{setting?.phone || '-'}

+

{setting?.site_address || 'Alamat Toko Belum Diatur'}

+

{setting?.site_phone || '-'}

@@ -147,7 +147,7 @@ export default function OrderShow({ order, setting }: ShowProps) {

Catatan:

- Terima kasih telah berbelanja di {setting?.name || 'VN Grup'}. + Terima kasih telah berbelanja di {setting?.site_name || 'VN Grup'}. Barang yang sudah dibeli tidak dapat ditukar atau dikembalikan kecuali ada perjanjian sebelumnya. Simpan invoice ini sebagai bukti pembelian yang sah.

@@ -181,7 +181,7 @@ export default function OrderShow({ order, setting }: ShowProps) {

Semoga hari Anda menyenangkan!

-

Generated by {setting?.name || 'VN Grup'} System

+

Generated by {setting?.site_name || 'VN Grup'} System

diff --git a/resources/js/pages/admin/system/settings/index.tsx b/resources/js/pages/admin/system/settings/index.tsx index 105a98a..d7b9ab1 100644 --- a/resources/js/pages/admin/system/settings/index.tsx +++ b/resources/js/pages/admin/system/settings/index.tsx @@ -17,10 +17,10 @@ export default function SettingIndex({ setting: GeneralSetting | null; }) { const { data, setData, post, processing, errors } = useForm({ - name: setting?.name || '', - description: setting?.description || '', - address: setting?.address || '', - phone: setting?.phone || '', + site_name: setting?.site_name || '', + site_description: setting?.site_description || '', + site_address: setting?.site_address || '', + site_phone: setting?.site_phone || '', logo_light: null as File | null, logo_dark: null as File | null, icon_light: null as File | null, @@ -107,41 +107,41 @@ export default function SettingIndex({
- -
-