PHP code example of wasimrasheed / e-wallet

1. Go to this page and download the library: Download wasimrasheed/e-wallet library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wasimrasheed / e-wallet example snippets


   'providers' => [
       ...
       Wasimrasheed\Ewallet\EwalletServiceProvider::class,
   ]
   
    'aliases' => [
         ...
         'EWallet' => Wasimrasheed\Ewallet\Facades\EWallet::class,
    ]
   

   php artisan migrate
   

createWallet(array $data): mixed:  Creates a new wallet with the provided data.
getWallet(int $id): array:  Retrieves the details of a specific wallet by its ID.
getWallets(): Collection:  Retrieves a collection of all wallets.
updateWallet(int $id, array $data): string:  Updates the wallet details for the specified wallet ID.
deleteWallet(int $id): string:  Deletes a wallet identified by its ID.
getWalletByColumn($item, $column): array:  Retrieves a wallet based on a specific column value.


$newWallet = EWallet::createWallet([
    'user_id' => $uuid,
    'balance' => 100.00,
]);

// Retrieve wallet details
$walletDetails = EWallet::getWallet($uuid);

// Retrieve all wallets
$allWallets = EWallet::getWallets();

// Update wallet
$updateMessage = EWallet::updateWallet($uuid, ['balance' => 150.00]);

// Delete wallet
$deleteMessage = EWallet::deleteWallet(1);

createTransaction(array $data): mixed: Creates a new transaction linked to a wallet.
getTransaction(int $id): array: Retrieves the details of a specific transaction by its ID.
getTransactionsByWallet(int $walletId): Collection: Retrieves the transaction history for a specific wallet.
updateTransaction(int $id, array $data): string: Updates the transaction details for the specified transaction ID.
deleteTransaction(int $id): string: Deletes a transaction identified by its ID.

use Wasimrasheed\EWallet\Http\Controllers\TransactionController;

// Create a new transaction
$newTransaction = EWallet::createTransaction([
'wallet_id' => 1,
'amount' => 50.00,
'type' => 'credit',
]);

// Retrieve transaction details
$transactionDetails = EWallet::getTransaction(1);

// Retrieve all transactions for a wallet
$walletTransactions = EWallet::getTransactionsByWallet(1);

// Update transaction
$transactionUpdateMessage = EWallet::updateTransaction(1, ['amount' => 75.00]);

// Delete transaction
$transactionDeleteMessage = EWallet::deleteTransaction(1);

createPaymentMethod(array $data): mixed: Creates a new payment method.
getPaymentMethod(int $id): array: Retrieves the details of a specific payment method by its ID.
getPaymentMethods(): Collection: Retrieves a collection of all payment methods.
updatePaymentMethod(int $id, array $data): string: Updates the payment method details for the specified ID.
deletePaymentMethod(int $id): string: Deletes a payment method identified by its ID.

use Wasimrasheed\EWallet\Http\Controllers\PaymentMethodController;

// Create a new payment method
$newPaymentMethod = EWallet::createPaymentMethod([
'name' => 'Credit Card',
'details' => 'Visa ending in 1234',
]);

// Retrieve payment method details
$paymentMethodDetails = EWallet::getPaymentMethod(1);

// Retrieve all payment methods
$allPaymentMethods = EWallet::getPaymentMethods();

// Update payment method
$paymentMethodUpdateMessage = EWallet::updatePaymentMethod(1, ['details' => 'Updated details']);

// Delete payment method
$paymentMethodDeleteMessage = EWallet::deletePaymentMethod(1);

createActivity(array $data): mixed: Logs a new activity related to wallets.
getActivity(int $id): array: Retrieves the details of a specific activity by its ID.
getActivities(): Collection: Retrieves a collection of all recorded activities.
updateActivity(int $id, array $data): string: Updates the details of a specific activity.
deleteActivity(int $id): string: Deletes an activity identified by its ID.

use Wasimrasheed\EWallet\Http\Controllers\ActivityController;

// Create a new activity
$activityController = new ActivityController();
$newActivity = EWallet::createActivity([
'wallet_id' => 1,
'description' => 'Deposit of $50',
]);

// Retrieve activity details
$activityDetails = EWallet::etActivity(1);

// Retrieve all activities
$allActivities = EWallet::getActivities();

// Update activity
$activityUpdateMessage = EWallet::updateActivity(1, ['description' => 'Updated description']);

// Delete activity
$activityDeleteMessage = EWallet::deleteActivity(1);