diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
new file mode 100644
index 0000000..21e9e4e
--- /dev/null
+++ b/app/Http/Controllers/AccountController.php
@@ -0,0 +1,63 @@
+paginate();
+
+ return inertia('Account/Index', [
+ 'query' => $query
+ ]);
+ }
+
+ public function store(Request $request)
+ {
+ $request->validate([
+ 'name' => 'required|string',
+ 'bank_name' => 'required|string',
+ 'holder_name' => 'required|string',
+ 'account_number' => 'required|string',
+ ]);
+
+ Account::create([
+ 'name' => $request->name,
+ 'bank_name' => $request->bank_name,
+ 'holder_name' => $request->holder_name,
+ 'account_number' => $request->account_number,
+ ]);
+
+ session()->flash('message', ['type' => 'success', 'message' => 'Item has been saved']);
+ }
+
+ public function update(Request $request, Account $account)
+ {
+ $request->validate([
+ 'name' => 'required|string',
+ 'bank_name' => 'required|string',
+ 'holder_name' => 'required|string',
+ 'account_number' => 'required|string',
+ ]);
+
+ $account->update([
+ 'name' => $request->name,
+ 'bank_name' => $request->bank_name,
+ 'holder_name' => $request->holder_name,
+ 'account_number' => $request->account_number,
+ ]);
+
+ session()->flash('message', ['type' => 'success', 'message' => 'Item has been updated']);
+ }
+
+ public function destroy(Account $account)
+ {
+ $account->delete();
+
+ session()->flash('message', ['type' => 'success', 'message' => 'Item has been deleted']);
+ }
+}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index a826c51..418ce73 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -14,7 +14,11 @@ class Authenticate extends Middleware
*/
protected function redirectTo($request)
{
- if (! $request->expectsJson()) {
+ if (!$request->expectsJson()) {
+ $uri = $request->getRequestUri();
+ if (str_contains($uri, 'admin')) {
+ return route('admin.login');
+ }
return route('customer.login');
}
}
diff --git a/database/seeders/DummySeeder.php b/database/seeders/DummySeeder.php
index 6df9eac..4204bde 100644
--- a/database/seeders/DummySeeder.php
+++ b/database/seeders/DummySeeder.php
@@ -2,6 +2,7 @@
namespace Database\Seeders;
+use App\Models\Account;
use App\Models\Banner;
use App\Models\Info;
use Illuminate\Database\Seeder;
@@ -17,6 +18,7 @@ class DummySeeder extends Seeder
{
$this->info();
$this->banner();
+ $this->account();
}
public function info()
@@ -38,4 +40,21 @@ class DummySeeder extends Seeder
]);
}
}
+
+ public function account()
+ {
+ $banks = [
+ ['name' => 'BRI', 'bank_name' => 'Bank Rakyat Indonesia', 'holder_name' => 'Aji Kamaludin', 'account_number' => '187391738129'],
+ ['name' => 'Jago', 'bank_name' => 'Bank Jago', 'holder_name' => 'Aji Kamaludin', 'account_number' => '718297389172']
+ ];
+
+ foreach ($banks as $bank) {
+ Account::create([
+ 'name' => $bank['name'],
+ 'bank_name' => $bank['bank_name'],
+ 'holder_name' => $bank['holder_name'],
+ 'account_number' => $bank['account_number'],
+ ]);
+ }
+ }
}
diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php
index fa3ac08..6bb62fe 100644
--- a/database/seeders/PermissionSeeder.php
+++ b/database/seeders/PermissionSeeder.php
@@ -78,6 +78,11 @@ class PermissionSeeder extends Seeder
['id' => Str::ulid(), 'label' => 'Update Coin Reward', 'name' => 'update-coin-reward'],
['id' => Str::ulid(), 'label' => 'View Coin Reward', 'name' => 'view-coin-reward'],
['id' => Str::ulid(), 'label' => 'Delete Coin Reward', 'name' => 'delete-coin-reward'],
+
+ ['id' => Str::ulid(), 'label' => 'Create Bank Account', 'name' => 'create-account'],
+ ['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'],
];
foreach ($permissions as $permission) {
diff --git a/resources/js/Layouts/Partials/routes.js b/resources/js/Layouts/Partials/routes.js
index 991bbc7..cde5bdb 100644
--- a/resources/js/Layouts/Partials/routes.js
+++ b/resources/js/Layouts/Partials/routes.js
@@ -5,7 +5,7 @@ import {
HiUserGroup,
HiInformationCircle,
} from 'react-icons/hi'
-import { HiQuestionMarkCircle } from 'react-icons/hi2'
+import { HiBanknotes, HiQuestionMarkCircle } from 'react-icons/hi2'
export default [
{
@@ -16,6 +16,14 @@ export default [
active: 'dashboard',
permission: 'view-dashboard',
},
+ {
+ name: 'Bank Akun',
+ show: true,
+ icon: HiBanknotes,
+ route: route('account.index'),
+ active: 'account.*',
+ permission: 'view-account',
+ },
{
name: 'Banner',
show: true,
diff --git a/resources/js/Pages/Account/FormModal.jsx b/resources/js/Pages/Account/FormModal.jsx
new file mode 100644
index 0000000..47a05c5
--- /dev/null
+++ b/resources/js/Pages/Account/FormModal.jsx
@@ -0,0 +1,108 @@
+import React, { useEffect } from 'react'
+import Modal from '@/Components/Modal'
+import { useForm } from '@inertiajs/react'
+import Button from '@/Components/Button'
+import FormInput from '@/Components/FormInput'
+import RoleSelectionInput from '../Role/SelectionInput'
+
+import { isEmpty } from 'lodash'
+
+export default function FormModal(props) {
+ const { modalState } = props
+ const { data, setData, post, put, processing, errors, reset, clearErrors } =
+ useForm({
+ name: '',
+ bank_name: '',
+ holder_name: '',
+ account_number: '',
+ })
+
+ const handleOnChange = (event) => {
+ setData(
+ event.target.name,
+ event.target.type === 'checkbox'
+ ? event.target.checked
+ ? 1
+ : 0
+ : event.target.value
+ )
+ }
+
+ const handleReset = () => {
+ modalState.setData(null)
+ reset()
+ clearErrors()
+ }
+
+ const handleClose = () => {
+ handleReset()
+ modalState.toggle()
+ }
+
+ const handleSubmit = () => {
+ const account = modalState.data
+ if (account !== null) {
+ put(route('account.update', account), {
+ onSuccess: () => handleClose(),
+ })
+ return
+ }
+ post(route('account.store'), {
+ onSuccess: () => handleClose(),
+ })
+ }
+
+ useEffect(() => {
+ const account = modalState.data
+ if (isEmpty(account) === false) {
+ setData({
+ name: account.name,
+ bank_name: account.bank_name,
+ holder_name: account.holder_name,
+ account_number: account.account_number,
+ })
+ return
+ }
+ }, [modalState])
+
+ return (
+
+ Nama + | ++ Atas Nama Rekening + | ++ Nomor Rekening + | ++ |
---|---|---|---|
+ {account.name} + | ++ {account.holder_name} + | ++ {account.account_number} + | +
+
+
+
+ Ubah
+
+
+
+
+ Hapus
+
+ |
+