PHPackages                             dnj/laravel-account - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dnj/laravel-account

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dnj/laravel-account
===================

v1.0.1(2y ago)1371MITPHPPHP ^8.1

Since Jan 31Pushed 2y ago2 watchersCompare

[ Source](https://github.com/dnj/laravel-account)[ Packagist](https://packagist.org/packages/dnj/laravel-account)[ RSS](/packages/dnj-laravel-account/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (3)Used By (0)

Management user account and transaction inside laravel app
==========================================================

[](#management-user-account-and-transaction-inside-laravel-app)

[![Latest Version on Packagist](https://camo.githubusercontent.com/85da8909fdadb6012a9ed218f3ca0f23b3eb167d62927e8dfc84d3c535b225e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646e6a2f6c61726176656c2d6163636f756e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dnj/laravel-account)[![Total Downloads](https://camo.githubusercontent.com/398c2b7cf58c4aa111a24a08b6ce30705f65a15b1ac7c38ed00a5824a4715e14/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646e6a2f6c61726176656c2d6163636f756e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dnj/laravel-account)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/dnj/laravel-account/blob/master/LICENSE)[![Testing status](https://github.com/dnj/local-filesystem/actions/workflows/test.yaml/badge.svg)](https://github.com/dnj/laravel-account/actions/workflows/test.yaml)[![Open API](https://camo.githubusercontent.com/c395240a1dcd622e5454d6a0c70ba4273b0662fa7afcc96ae3ab55087c50feb2/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f636f6c6f723d626c7565266c6162656c3d6f70656e415049266c6f676f3d253232253233364241353339253232266c6f676f436f6c6f723d626c7565267374796c653d666f722d7468652d62616467652675726c3d6874747073253341253246253246696d672e736869656c64732e696f253246656e64706f696e7425334675726c25334468747470732533412532462532466769746875622e636f6d253246646e6a2532466c61726176656c2d6163636f756e74253246626c6f622532466d6173746572253246617069446f63732532466163636f756e742e6a736f6e)](https://github.com/dnj/laravel-account/blob/master/openapi.json)

Introduction
------------

[](#introduction)

The dnj/laravel-account package provides easy way to manage accounts and transactions of the users in your app. The Package stores all data in the accounts and transactions table.

- Latest versions of PHP and PHPUnit and PHPCsFixer
- Best practices applied:
    - [`README.md`](https://github.com/dnj/laravel-account/blob/master/README.md) (badges included)
    - [`LICENSE`](https://github.com/dnj/laravel-account/blob/master/LICENSE)
    - [`composer.json`](https://github.com/dnj/laravel-account/blob/master/composer.json)
    - [`phpunit.xml`](https://github.com/dnj/laravel-account/blob/master/phpunit.xml)
    - [`.gitignore`](https://github.com/dnj/laravel-account/blob/master/.gitignore)
    - [`.php-cs-fixer.php`](https://github.com/dnj/laravel-account/blob/master/.php-cs-fixer.php)
    - [`Open Api 3`](https://github.com/dnj/laravel-account/blob/master/openapi.json)
- Some useful resources to start coding

Here's a demo of how you can use it:
------------------------------------

[](#heres-a-demo-of-how-you-can-use-it)

```
use dnj\Account\Contracts\IAccount;
use dnj\Account\Contracts\IAccountManager;
use dnj\Account\Contracts\AccountStatus;
use dnj\Currency\Contracts\ICurrencyManager;

$currencyManager = app(ICurrencyManager::class);
$currency = $currencyManager->firstByCode("USD");

$accountManager = app(IAccountManager::class);

/**
 * @var IAccount $account
 */
$account = $accountManager->create(
    title: 'Profits',
    userId: Auth::user()->id,
    currencyId: $currency->getId(),
    status: AccountStatus::ACTIVE,
    canSend: true,
    canReceive: true,
    meta: ["key" => "value"],
    userActivityLog: true
);
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require dnj/laravel-account
```

The package will automatically register itself.

After this you can create required tables by running the migrations:

```
php artisan migrate
```

You can optionally publish the config file with:

```
php artisan vendor:publish --provider="dnj\Account\AccountServiceProvider" --tag="config"
```

Config file:

```
return [
    // Define your user model class for connect accounts to users. Example: App\User:class
    'user_model' => null,

    // Enable http restful routes.
    'route_enable' => true,

    // Prefix of routes. By default routes register with /api/{prefix}/{accounts|transactions} pattern.
    'route_prefix' => null,
];
```

Working With Accounts
---------------------

[](#working-with-accounts)

Create new account:

```
use dnj\Account\Contracts\IAccount;
use dnj\Account\Contracts\IAccountManager;
use dnj\Account\Contracts\AccountStatus;
use dnj\Currency\Contracts\ICurrencyManager;

$currencyManager = app(ICurrencyManager::class);
$currency = $currencyManager->firstByCode("USD");

$accountManager = app(IAccountManager::class);

/**
 * @var IAccount $account
 */
$account = $accountManager->create(
    title: 'Profits',
    userId: Auth::user()->id,
    currencyId: $currency->getId(),
    status: AccountStatus::ACTIVE,
    canSend: true,
    canReceive: true,
    meta: ["key" => "value"],
    userActivityLog: true
);
```

Update account:

```
use dnj\Account\Contracts\IAccountManager;
use dnj\Account\Contracts\AccountStatus;

$accountManager = app(IAccountManager::class);
$account = $accountManager->update(
    accountId: 2,
    changes: array(
        'status' => AccountStatus::DEACTIVE,
    ),
    userActivityLog: true
);
```

Destroy account:

```
use dnj\Account\Contracts\IAccountManager;

$accountManager = app(IAccountManager::class);
$accountManager->delete(
    accountId: $account->getId(),
    userActivityLog: true
);
```

---

Working With Transactions
-------------------------

[](#working-with-transactions)

Create transaction:

```
use dnj\Account\Contracts\IAccountManager;
use dnj\Account\Contracts\ITransactionManager;
use dnj\Account\Contracts\ITransaction;
use dnj\Number\Number;

$accountManager = app(IAccountManager::class);

$profits = $accountManager->getByID(1);
$salary = $accountManager->getByID(2);

$transactionManager = app(ITransactionManager::class);

/**
 * @var ITransaction $transaction
 */
$transaction = $transactionManager->transfer(
    fromAccountId: $profits->getId(),
    toAccountId: $salary->getId(),
    amount: Number::fromInput(2501.55),
    meta: [
        'month' => '2023-01'
    ],
    force: false,
    userActivityLog: true
);
```

Update transaction:

```
use dnj\Account\Contracts\ITransactionManager;
use dnj\Account\Contracts\ITransaction;

$transactionManager = app(ITransactionManager::class);

/**
 * @var ITransaction $transaction
 */
$transaction = $transactionManager->update(
    transactionId: 55,
    meta: [
        'month' => '2023-01',
        'over-time' => 21
    ]
);
```

Rollback transaction:

```
use dnj\Account\Contracts\ITransactionManager;
use dnj\Account\Contracts\ITransaction;

$transactionManager = app(ITransactionManager::class);

/**
 * @var ITransaction $rollbackTransaction new transaction that just made for rollback
 */
$rollbackTransaction = $transactionManager->rollback(55);
```

How to use package API
----------------------

[](#how-to-use-package-api)

A document in YAML format has been prepared for better familiarization and use of package web services. which is placed in the [`openapi.json`](https://github.com/dnj/laravel-account/blob/master/openapi.json) file.

To use this file, you can import it on the [Swagger](link-swagger) site and see all available methods.

Contribution
------------

[](#contribution)

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

Testing
-------

[](#testing)

You can run unit tests with PHP Unit:

```
./vendor/bin/phpunit
```

About
-----

[](#about)

We'll try to maintain this project as simple as possible, but Pull Requests are welcomed!

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/dnj/laravel-account/blob/master/LICENSE) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~217 days

Total

2

Last Release

978d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/73cf0aeb62f80ed9937e3a39a8dfda10b94c36cc7028e9f0a95e04eb8a346db4?d=identicon)[dnj](/maintainers/dnj)

---

Top Contributors

[![yeganemehr](https://avatars.githubusercontent.com/u/16887332?v=4)](https://github.com/yeganemehr "yeganemehr (22 commits)")[![HamidNiakan](https://avatars.githubusercontent.com/u/26175246?v=4)](https://github.com/HamidNiakan "HamidNiakan (15 commits)")

---

Tags

accountingfinanciallaravelphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dnj-laravel-account/health.svg)

```
[![Health](https://phpackages.com/badges/dnj-laravel-account/health.svg)](https://phpackages.com/packages/dnj-laravel-account)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
