1. Go to this page and download the library: Download hamadou/fundry 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/ */
hamadou / fundry example snippets
// app/Models/User.php
use Hamadou\Fundry\Traits\HasWallets;
class User extends Authenticatable
{
use HasWallets;
// ... vos autres traits et méthodes
}
use Hamadou\Fundry\DTOs\DepositDTO;
$dto = new DepositDTO(
userId: $user->id,
walletId: $wallet->id,
amount: 1000.00,
description: 'Dépôt initial',
commissionPercentage: 2.5 // 2.5% de commission
);
$transaction = Fundry::depositWithDTO($dto);
// Le montant net déposé sera 975.00 (1000 - 2.5%)
// La commission sera 25.00
use Hamadou\Fundry\DTOs\WithdrawalDTO;
$dto = new WithdrawalDTO(
userId: $user->id,
walletId: $wallet->id,
amount: 500.00, // Montant net retiré
description: 'Retrait',
commissionPercentage: 1.0 // 1% de commission
);
$transaction = Fundry::withdrawWithDTO($dto);
// Le montant total débité sera 505.00 (500 + 1%)
// La commission sera 5.00
use Hamadou\Fundry\DTOs\TransferDTO;
$dto = new TransferDTO(
userId: $user->id,
fromWalletId: $wallet1->id,
toWalletId: $wallet2->id,
amount: 1000.00,
description: 'Transfert entre comptes',
commissionPercentage: 1.5 // 1.5% de commission
);
$transaction = Fundry::transferWithDTO($dto);
// 1015.00 sera débité du wallet source
// 985.00 sera crédité au wallet destination
// 15.00 sera la commission
// Créer un portefeuille
$wallet = $user->createWallet([
'currency_id' => $currency->id,
'name' => 'Mon Wallet',
'type' => WalletType::PERSONAL,
]);
// Récupérer un portefeuille par devise
$usdWallet = $user->getWalletByCurrency('USD');
// Portefeuille par défaut
$defaultWallet = $user->getDefaultWallet();
// Solde dans une devise
$balance = $user->getWalletBalance('USD');
// Solde total en USD
$totalUsd = $user->getTotalBalanceInUsd();
// Vérifier si le solde est suffisant
if ($user->hasSufficientBalance(500, 'USD')) {
// Le solde est suffisant
}
// Portefeuilles par type
$businessWallets = $user->getWalletsByType(WalletType::BUSINESS);
// Par code ISO 4217 (avec cache)
$usd = Currency::findByIsoCode('USD');
// Par pays
$france = Country::findByIsoCode('FR');
$euro = $france->currencies()->first();
// Par code devise du pays
$country = Country::where('currency_code', 'EUR')->first();
// Créer un portefeuille
Fundry::createWallet($user, array $data): Wallet
// Obtenir le solde
Fundry::getWalletBalance(Wallet $wallet): float
// Historique des transactions
Fundry::getWalletHistory(Wallet $wallet, int $limit = 50): Collection
// Transfert simple
Fundry::transfer(Wallet $from, Wallet $to, float $amount, ?string $description): Transaction
// Transfert avec DTO
Fundry::transferWithDTO(TransferDTO $dto): Transaction
// Vérifier les limites du wallet
$wallet->min_balance;
$wallet->transaction_limit;
$wallet->max_balance;
// Vérifier si le retrait est possible
if ($wallet->canWithdraw($amount)) {
// OK
}
use Hamadou\Fundry\Services\CurrencyService;
$currencyService = app(CurrencyService::class);
$currencyService->clearCache();
// Vérifier l'appartenance avant l'opération
if (!$wallet->belongsToUser($user)) {
throw new UnauthorizedWalletException();
}
bash
# Publier les migrations
php artisan vendor:publish --tag=fundry-migrations
# Publier la configuration
php artisan vendor:publish --tag=fundry-config
bash
php artisan migrate
bash
# Synchroniser les pays
php artisan fundry:sync-countries
# Seeder les devises principales
php artisan db:seed --class="Hamadou\Fundry\Seeders\CurrencySeeder"
🔍 Validation des devises...
✅ Toutes les devises sont valides!
📊 Total de devises validées: 25
bash
php artisan fundry:update-rates
bash
# Mode manuel (aucune mise à jour automatique)
php artisan fundry:update-rates
# Avec ExchangeRate-API
php artisan fundry:update-rates \
--provider=exchangerate-api \
--api-key=your_api_key_here \
--base=USD
🔄 Mise à jour des taux de change (Provider: exchangerate-api, Base: USD)...
🌐 Récupération des taux depuis ExchangeRate-API...
✅ 25 taux de change mis à jour avec succès!
📊 Exemples de taux mis à jour:
• EUR: 1.1
• GBP: 1.27
• XOF: 0.0017
• MAD: 0.10
• TND: 0.32
bash
php artisan fundry:currencies {action?}
bash
php artisan fundry:cash {action?}
bash
php artisan fundry:crypto {action?}
bash
php artisan fundry:report {type} [options]
bash
# Rapport des transactions en PDF
php artisan fundry:report transactions --format=pdf
# Rapport des transactions en Excel avec filtres
php artisan fundry:report transactions \
--format=excel \
--start-date=2024-01-01 \
--end-date=2024-12-31 \
--user-id=1 \
--currency=USD
# Rapport des portefeuilles
php artisan fundry:report wallets --format=pdf --wallet-type=personal
# Rapport des devises
php artisan fundry:report currencies --format=excel
# Rapport avec fichier de sortie personnalisé
php artisan fundry:report transactions \
--format=pdf \
--output=rapport_janvier_2024
bash
# Vérifier que les devises sont bien seedées
php artisan fundry:validate-currencies
# Re-seeder si nécessaire
php artisan db:seed --class="Hamadou\Fundry\Seeders\CurrencySeeder"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.