<?php

namespace App\Services;

use App\Models\Wallet;
use Slowlyo\OwlAdmin\Services\AdminService;

/**
 * 钱包
 *
 * @method Wallet getModel()
 * @method Wallet|\Illuminate\Database\Query\Builder query()
 */
class WalletService extends AdminService
{
	protected string $modelName = Wallet::class;

	public function list()
	{
		$data = parent::list();
		$userState = admin_dict()->getAll('user_status');
		$walletType = admin_dict()->getAll('wallet_type');
		collect($data['items'])->each(function ($item) use ($userState, $walletType) {
			$item->state = $userState[$item->state]['value'] ?? $item->state;
			$item->owner_type = $walletType[$item->owner_type]['value'] ?? $item->owner_type;
			$item->load('member');
		});
        return $data;
	}
}