{"id":51045346,"url":"https://github.com/whilesmartphp/eloquent-accounts","last_synced_at":"2026-06-22T13:03:04.074Z","repository":{"id":353774759,"uuid":"1219362873","full_name":"whilesmartphp/eloquent-accounts","owner":"whilesmartphp","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-25T13:23:36.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-04-25T14:25:13.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whilesmartphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-23T19:55:39.000Z","updated_at":"2026-04-25T13:23:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/whilesmartphp/eloquent-accounts","commit_stats":null,"previous_names":["whilesmartphp/eloquent-accounts"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/whilesmartphp/eloquent-accounts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-accounts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-accounts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-accounts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-accounts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilesmartphp","download_url":"https://codeload.github.com/whilesmartphp/eloquent-accounts/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-accounts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34649822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-22T13:03:03.178Z","updated_at":"2026-06-22T13:03:04.069Z","avatar_url":"https://github.com/whilesmartphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eloquent Accounts\n\nPolymorphic financial account records for Laravel. Bank accounts, mobile money wallets, card processors, cash registers, crypto wallets. Attaches on the account side of `whilesmart/eloquent-payments` and `whilesmart/eloquent-expenses`.\n\n## Why\n\n`eloquent-payments` and `eloquent-expenses` both carry a nullable `account` polymorph. Without a concrete account model those fields go unused; reporting can't answer \"what's in the Lagos UBA account right now?\" or \"how much came in through MTN MoMo this month?\"\n\nThis package fills that gap. It is optional: if you don't install it, the morph columns on payments / expenses stay null and nothing breaks.\n\n## Install\n\n```\ncomposer require whilesmart/eloquent-accounts\nphp artisan migrate\n```\n\nAttach `HasAccounts` to the model that owns accounts (typically a workspace):\n\n```php\nuse Whilesmart\\Accounts\\Traits\\HasAccounts;\n\nclass Workspace extends Model\n{\n    use HasAccounts;\n}\n```\n\n## Data model\n\nOne `accounts` table. Each row belongs polymorphically to an owner and holds:\n\n- **Identity**: `name`, `type` (`bank | mobile_money | card_processor | wallet | cash | crypto | other`), `status` (`active | closed | frozen`).\n- **Provider**: `provider` (string, e.g. `UBA`, `MTN MoMo`, `Stripe`), `provider_reference`, `identifier` (account number / last 4 / wallet number, safe to display).\n- **Money**: `currency`, `opening_balance_cents`, `balance_cents`.\n- **`is_primary`**: default account for its owner + currency. Helper `primaryAccount(string $currency = null)` on the owner.\n- **`metadata`**: JSON.\n\n`type` and `provider` are free-form strings at the DB level so new rails don't need migrations; `AccountType` enum carries the canonical values.\n\n## Balance\n\nTwo modes:\n\n1. **Computed** (default, `ACCOUNTS_COMPUTE_BALANCE=true`): when you read an account, `balance_cents` is derived as `opening_balance_cents + succeeded inbound payments - succeeded outbound payments - paid expenses`. Requires `whilesmart/eloquent-payments` and/or `whilesmart/eloquent-expenses`; gracefully degrades if they are not installed.\n2. **Stored** (`ACCOUNTS_COMPUTE_BALANCE=false`): reads the `balance_cents` column. Call `$account-\u003erefreshBalance()` (or `POST /api/accounts/{id}/refresh-balance`) to recompute and persist.\n\n## Routes\n\n```\nGET    /api/accounts\nPOST   /api/accounts\nGET    /api/accounts/{account}\nPUT    /api/accounts/{account}\nDELETE /api/accounts/{account}\nPOST   /api/accounts/{account}/refresh-balance\n```\n\nIndex filters: `owner_type`, `owner_id`, `type`, `status`, `currency`, `q`, `per_page`.\n\n## Config\n\n`php artisan vendor:publish --tag=accounts-config`:\n\n```php\nreturn [\n    'register_routes' =\u003e env('ACCOUNTS_REGISTER_ROUTES', true),\n    'route_prefix' =\u003e env('ACCOUNTS_ROUTE_PREFIX', 'api'),\n    'route_middleware' =\u003e ['api', 'auth:sanctum'],\n    'table' =\u003e env('ACCOUNTS_TABLE', 'accounts'),\n    'compute_balance' =\u003e env('ACCOUNTS_COMPUTE_BALANCE', true),\n];\n```\n\n## Siblings\n\n- `whilesmart/eloquent-payments` -- inbound / outbound transfers. Each Payment has `account_type` + `account_id`.\n- `whilesmart/eloquent-expenses` -- expenses, paid from accounts.\n- `whilesmart/eloquent-invoices` -- invoices (money in). Tracks summary totals on the invoice row; actual payment records live in `eloquent-payments`, which reference an Account.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-accounts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilesmartphp%2Feloquent-accounts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-accounts/lists"}