承接 open-nebel/ewallet 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

open-nebel/ewallet

Composer 安装命令:

composer require open-nebel/ewallet

包简介

Laravel Package to Easy work with virtual wallet

README 文档

README

Social Card of Laravel E-wallet

Manage Wallet and More with Eloquent Models

Installation

You can install the package via composer:

composer require open-nebel/ewallet

You can publish and run the migrations with:

php artisan vendor:publish "OpenNebel\EWallet\Providers\EWalletServiceProvider"  
php artisan migrate

Usage

Prepare User Model

  • app/Models/User.php
use OpenNebel\EWallet\Interfaces\Wallet;
use OpenNebel\EWallet\Traits\HasWallet;

class User extends Authenticatable implements Wallet
{
    use HasWallet;
}
  • config/wallet.php
<?php

return [
    "owner_model" => "App\Models\User",
];

Manage Wallets

    $user = User::find(1);
    
    // Add Wallet with default name and default currency
    $user->addWallet();
    
    // or Add Wallet with name and currency
    $user->addWallet(name: "Text", currency: $currency->id);
    
    // Or Add Wallet with balance
    $user->addWallet(balance: 1000);

    $user->getWallets();
    // RESULTAT
    [
        {
            "id": 1,
            "name": "US Dollar Wallet",
            "owner_type": "App\\Models\\User",
            "owner_id": 1,
            "balance": "0.00",
            "currency_id": 7,
            "created_at": "2024-01-09T09:38:25.000000Z",
            "updated_at": "2024-01-09T09:38:25.000000Z"
        },
        {
            "id": 2,
            "name": "Text",
            "owner_type": "App\\Models\\User",
            "owner_id": 1,
            "balance": "0.00",
            "currency_id": 10,
            "created_at": "2024-01-09T09:56:43.000000Z",
            "updated_at": "2024-01-09T09:56:43.000000Z"
        }
    ]

    // Retrieve a specific wallet
    $wallet = Wallet::find(1);
    
    $user->getWallet($wallet); // by instance
    
    $user->getWallet(1); // by ID
    
    $user->getWallet("US Dollar Wallet"); // by name

    // RESULT
    {
        "id": 1,
        "name": "US Dollar Wallet",
        "owner_type": "App\\Models\\User",
        "owner_id": 1,
        "balance": "0.00",
        "currency_id": 7,
        "created_at": "2024-01-09T09:38:25.000000Z",
        "updated_at": "2024-01-09T09:38:25.000000Z"
    }

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-08