D
Engineering

wallets

Skema koleksi wallets — balance, bank_accounts embedded, accessor virtual, SoftDeletes.

Koleksi utama wallet merchant. Satu wallet per store.

Definisi model

app/Models/Wallet.phpWallet extends MongoDB\Laravel\Eloquent\Model

PropertiNilaiSumber
CollectionwalletsWallet.php:15
ConnectionmongodbWallet.php:14
$guarded[] (mass-assign semua)Wallet.php:17
$hidden['pin_hash']Wallet.php:22-24
SoftDeletesWallet.php:12
Primary keyUUID stringWallet.php:18-20,44-46

Field

FieldTipeDefaultCastSumber
idstring UUIDgeneratedWallet.php:45
store_idstringWalletService.php:91
user_idstringWalletService.php:92
doku_sub_account_idstringWalletService.php:93
pin_hashstring (bcrypt)WalletService.php:94
statusstring'inactive'Wallet.php:35, WalletService.php:95 ('active')
balanceinteger0integerWallet.php:33,26
pending_balanceinteger0integerWallet.php:34,27
activated_atdatetime (Carbon)datetimeWalletService.php:96, Wallet.php:29
processing_balanceinteger (virtual)accessor Wallet.php:78-84
available_balanceinteger (virtual)accessor Wallet.php:100-123
total_withdrawninteger (virtual)accessor Wallet.php:89-95
bank_accountsarray of object[]WalletController.php:595
deleted_atdatetimeSoftDeletes
created_atdatetime (BSON)auto
updated_atdatetime (BSON)auto

bank_accounts (embedded array)

Dari WalletController.php:570-577:

json
[
  {
    "id": "uuid",
    "bank_code": "string max 12",
    "bank_name": "string max 100",
    "account_number": "string 10-20 digit",
    "account_name": "string max 40",
    "created_at": "ISO8601 string"
  }
]

Relasi

NamaTipeFKSumber
storebelongsToStore.idstore_idWallet.php:50-52
userbelongsToUser.iduser_idWallet.php:53-55
transactionshasManyWalletTransaction.wallet_ididWallet.php:57-63

Index & constraint

  • Tidak ada index didefinisikan di model
  • Tidak ada unique constraint di DB
  • Primary key: UUID string

Contoh dokumen

json
{
  "_id": ObjectId("..."),
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "store_id": "<store.id>",
  "user_id": "<user.id>",
  "doku_sub_account_id": "DOKU-xxx",
  "pin_hash": "$2y$...",
  "status": "active",
  "balance": 150000,
  "pending_balance": 0,
  "processing_balance": 0,
  "total_withdrawn": 0,
  "activated_at": ISODate("2026-01-01T00:00:00Z"),
  "bank_accounts": [
    {
      "id": "uuid-acc-1",
      "bank_code": "014",
      "bank_name": "BCA",
      "account_number": "1234567890",
      "account_name": "John Doe",
      "created_at": "2026-01-01T00:00:00+00:00"
    }
  ],
  "created_at": ISODate("..."),
  "updated_at": ISODate("...")
}

Seeder

database/seeders/BackfillWalletFieldsSeeder.php — hanya menambahkan default processing_balance=0 ke wallets existing. Tidak ada seeder untuk create contoh data.

Referensi

  • Alur Wallet — alur topup & withdraw
  • app/Models/Wallet.php — model
  • app/Services/WalletService.php — service
  • app/Http/Controllers/WalletController.php — controller