diff --git a/TODO.md b/TODO.md
index c4ba83b..b35473a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -6,11 +6,12 @@
- [x] CRUD Banner
- [x] CRUD Rekening / Account
- [x] CRUD Customer
+- [ ] CRUD Lokasi
- [ ] CRUD Voucher
- [ ] Import Voucher
- [ ] Deposit Menu (view daftar histori deposit)
- [ ] Manual Approve Deposit
-- [ ] Setting Web (enable affilate, amount bonus affilate)
+- [x] Setting Web (enable affilate, amount bonus affilate)
- [ ] Setting Bonus Coin (memasukan amount bonus coin yang didapat dengan level dan harga voucher) - coin rewards
- [ ] Setting Level Customer (view levels, edit name of level,minimal saldo, max amount saldo, max hutang)
- [ ] View Customer Coin History
diff --git a/app/Http/Controllers/LocationController.php b/app/Http/Controllers/LocationController.php
new file mode 100644
index 0000000..6f75150
--- /dev/null
+++ b/app/Http/Controllers/LocationController.php
@@ -0,0 +1,10 @@
+ $setting,
+ 'midtrans_notification_url' => route('api.midtrans.notification')
+ ]);
+ }
+
+ public function update(Request $request)
+ {
+ $request->validate([
+ 'AFFILATE_ENABLED' => 'required|in:0,1',
+ 'AFFILATE_COIN_AMOUNT' => 'required|numeric',
+ 'MIDTRANS_SERVER_KEY' => 'required|string',
+ 'MIDTRANS_CLIENT_KEY' => 'required|string',
+ 'MIDTRANS_MERCHANT_ID' => 'required|string',
+ 'MIDTRANS_ENABLED' => 'required|in:0,1',
+ 'midtrans_logo_file' => 'nullable|image',
+ ]);
+
+ DB::beginTransaction();
+ foreach ($request->except(['midtrans_logo_file']) as $key => $value) {
+ Setting::where('key', $key)->update(['value' => $value]);
+ }
+
+ if ($request->hasFile('midtrans_logo_file')) {
+ $file = $request->file('midtrans_logo_file');
+ $file->store('uploads', 'public');
+ Setting::where('key', 'MIDTRANS_LOGO')->update(['value' => $file->hashName('uploads')]);
+ }
+
+ DB::commit();
+
+ session()->flash('message', ['type' => 'success', 'message' => 'Setting has beed saved']);
+ }
+}
diff --git a/app/Models/Setting.php b/app/Models/Setting.php
index f45947e..1e0c4b0 100644
--- a/app/Models/Setting.php
+++ b/app/Models/Setting.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -16,4 +17,19 @@ class Setting extends Model
'value',
'type',
];
+
+ protected $appends = [
+ 'url',
+ ];
+
+ protected function url(): Attribute
+ {
+ return Attribute::make(get: function () {
+ if ($this->type == 'image') {
+ return asset($this->value);
+ }
+
+ return '';
+ });
+ }
}
diff --git a/database/seeders/InstallationSeed.php b/database/seeders/InstallationSeed.php
index 6d7ad00..c2d25fb 100644
--- a/database/seeders/InstallationSeed.php
+++ b/database/seeders/InstallationSeed.php
@@ -20,14 +20,14 @@ class InstallationSeed extends Seeder
public function settings()
{
$settings = [
- ['key' => 'AFFILATE_ENABLE', 'value' => '0', 'type' => 'checkbox'],
- ['key' => 'AFFILATE_AMOUNT', 'value' => '0', 'type' => 'text'],
+ ['key' => 'AFFILATE_ENABLED', 'value' => '0', 'type' => 'checkbox'],
+ ['key' => 'AFFILATE_COIN_AMOUNT', 'value' => '0', 'type' => 'text'],
['key' => 'MIDTRANS_SERVER_KEY', 'value' => 'SB-Mid-server-UA0LQbY4aALV0CfLLX1v7xs8', 'type' => 'text'],
['key' => 'MIDTRANS_CLIENT_KEY', 'value' => 'SB-Mid-client-xqqkspzoZOM10iUG', 'type' => 'text'],
['key' => 'MIDTRANS_MERCHANT_ID', 'value' => 'G561244367', 'type' => 'text'],
-
- //
+ ['key' => 'MIDTRANS_LOGO', 'value' => 'sample/midtrans_logo.png', 'type' => 'image'],
+ ['key' => 'MIDTRANS_ENABLED', 'value' => '0', 'type' => 'text'],
];
foreach ($settings as $setting) {
diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php
index 6bb62fe..5a12655 100644
--- a/database/seeders/PermissionSeeder.php
+++ b/database/seeders/PermissionSeeder.php
@@ -83,6 +83,11 @@ class PermissionSeeder extends Seeder
['id' => Str::ulid(), 'label' => 'Update Bank Account', 'name' => 'update-account'],
['id' => Str::ulid(), 'label' => 'View Bank Account', 'name' => 'view-account'],
['id' => Str::ulid(), 'label' => 'Delete Bank Account', 'name' => 'delete-account'],
+
+ ['id' => Str::ulid(), 'label' => 'Create Lokasi', 'name' => 'create-location'],
+ ['id' => Str::ulid(), 'label' => 'Update Lokasi', 'name' => 'update-location'],
+ ['id' => Str::ulid(), 'label' => 'View Lokasi', 'name' => 'view-location'],
+ ['id' => Str::ulid(), 'label' => 'Delete Lokasi', 'name' => 'delete-location'],
];
foreach ($permissions as $permission) {
diff --git a/public/sample/midtrans_logo.png b/public/sample/midtrans_logo.png
new file mode 100644
index 0000000..a8309f6
Binary files /dev/null and b/public/sample/midtrans_logo.png differ
diff --git a/public/uploads/5SmLKPkZsSsosDLC4lOSuDwuOChLU73drcOrKoNd.png b/public/uploads/5SmLKPkZsSsosDLC4lOSuDwuOChLU73drcOrKoNd.png
new file mode 100644
index 0000000..a8309f6
Binary files /dev/null and b/public/uploads/5SmLKPkZsSsosDLC4lOSuDwuOChLU73drcOrKoNd.png differ
diff --git a/public/uploads/XWztTeRNi8ATbkoQ3MGuZ2k0J1sjA28roZvu8nei.png b/public/uploads/XWztTeRNi8ATbkoQ3MGuZ2k0J1sjA28roZvu8nei.png
new file mode 100644
index 0000000..b6f830c
Binary files /dev/null and b/public/uploads/XWztTeRNi8ATbkoQ3MGuZ2k0J1sjA28roZvu8nei.png differ
diff --git a/resources/js/Layouts/Partials/routes.js b/resources/js/Layouts/Partials/routes.js
index 5a12b28..0dd1444 100644
--- a/resources/js/Layouts/Partials/routes.js
+++ b/resources/js/Layouts/Partials/routes.js
@@ -4,6 +4,7 @@ import {
HiUsers,
HiUserGroup,
HiInformationCircle,
+ HiCog,
} from 'react-icons/hi'
import {
HiBanknotes,
@@ -37,6 +38,14 @@ export default [
active: 'account.*',
permission: 'view-account',
},
+ {
+ name: 'Setting',
+ show: true,
+ icon: HiCog,
+ route: route('setting.index'),
+ active: 'setting.*',
+ permission: 'view-setting',
+ },
{
name: 'Front Home',
show: true,
diff --git a/resources/js/Pages/Setting/Index.jsx b/resources/js/Pages/Setting/Index.jsx
new file mode 100644
index 0000000..d1ca87a
--- /dev/null
+++ b/resources/js/Pages/Setting/Index.jsx
@@ -0,0 +1,146 @@
+import React from 'react'
+import { Head, router, useForm } from '@inertiajs/react'
+
+import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
+import FormInput from '@/Components/FormInput'
+import Button from '@/Components/Button'
+import TextArea from '@/Components/TextArea'
+import FormFile from '@/Components/FormFile'
+import Checkbox from '@/Components/Checkbox'
+import { extractValue } from './utils'
+
+export default function General(props) {
+ const { setting, midtrans_notification_url } = props
+ const { data, setData, post, reset, processing, errors } = useForm({
+ AFFILATE_ENABLED: extractValue(setting, 'AFFILATE_ENABLED'),
+ AFFILATE_COIN_AMOUNT: extractValue(setting, 'AFFILATE_COIN_AMOUNT'),
+ MIDTRANS_SERVER_KEY: extractValue(setting, 'MIDTRANS_SERVER_KEY'),
+ MIDTRANS_CLIENT_KEY: extractValue(setting, 'MIDTRANS_CLIENT_KEY'),
+ MIDTRANS_MERCHANT_ID: extractValue(setting, 'MIDTRANS_MERCHANT_ID'),
+ MIDTRANS_LOGO: extractValue(setting, 'MIDTRANS_LOGO'),
+ MIDTRANS_ENABLED: extractValue(setting, 'MIDTRANS_ENABLED'),
+ midtrans_logo_file: null,
+ })
+
+ const handleOnChange = (event) => {
+ setData(
+ event.target.name,
+ event.target.type === 'checkbox'
+ ? event.target.checked
+ ? 1
+ : 0
+ : event.target.value
+ )
+ }
+
+ const handleSubmit = () => {
+ post(route('setting.update'), {
+ onSuccess: () => {
+ setTimeout(() => router.get(route(route().current())), 3000)
+ },
+ })
+ }
+
+ return (
+