PHPackages                             whilesmart/eloquent-expenses - 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. [Database &amp; ORM](/categories/database)
4. /
5. whilesmart/eloquent-expenses

ActiveLibrary[Database &amp; ORM](/categories/database)

whilesmart/eloquent-expenses
============================

Polymorphic expense tracking for Laravel applications.

1.1.0(1mo ago)038MITPHPPHP ^8.2CI passing

Since Jun 11Pushed 1mo agoCompare

[ Source](https://github.com/whilesmartphp/eloquent-expenses)[ Packagist](https://packagist.org/packages/whilesmart/eloquent-expenses)[ RSS](/packages/whilesmart-eloquent-expenses/feed)WikiDiscussions dev Synced 3w ago

READMEChangelog (2)Dependencies (5)Versions (6)Used By (0)

Eloquent Expenses
=================

[](#eloquent-expenses)

Polymorphic expense tracking for Laravel. Money-out counterpart to `whilesmart/eloquent-invoices`.

Install
-------

[](#install)

```
composer require whilesmart/eloquent-expenses
php artisan migrate

```

Attach `HasExpenses` to the model that owns expenses (workspace / organisation / user):

```
use Whilesmart\Expenses\Traits\HasExpenses;

class Workspace extends Model
{
    use HasExpenses;
}
```

Attach `IsVendor` to any model that can be a vendor:

```
use Whilesmart\Expenses\Contracts\Vendor;
use Whilesmart\Expenses\Traits\IsVendor;

class Supplier extends Model implements Vendor
{
    use IsVendor;
}
```

Data model
----------

[](#data-model)

Two polymorphic relations plus a vendor name snapshot:

- **`owner`** -- who the expense is booked against (required).
- **`vendor`** -- who was paid, optional polymorphic link (`vendor_type` + `vendor_id`).
- **`vendor_name`** -- snapshot string; used when there is no linked record, or to preserve the display name at entry time so future vendor renames don't mutate history.

Other fields: `number`, `category`, `description`, `amount_cents`, `tax_cents`, `total_cents`, `currency`, `status` (`draft | submitted | approved | paid | rejected`), `payment_method`, `incurred_at`, `paid_at`, `receipt_url`, `notes`, `metadata`.

Routes
------

[](#routes)

Registers an `apiResource` at the configured prefix (default `api`, middleware `['api', 'auth:sanctum']`):

```
GET    /api/expenses
POST   /api/expenses
GET    /api/expenses/{expense}
PUT    /api/expenses/{expense}
DELETE /api/expenses/{expense}

```

Index filters: `owner_type`, `owner_id`, `vendor_type`, `vendor_id`, `status`, `category`, `from`, `to`, `q`, `per_page`.

Relationship to other packages
------------------------------

[](#relationship-to-other-packages)

- **`whilesmart/eloquent-invoices`** -- invoices are money in; expenses are money out. Same polymorphic owner pattern.
- **`whilesmart/eloquent-payments`** (sibling package) -- when you settle an expense through a gateway, record a `Payment` against the expense. `payment_method` on the expense is a summary; `Payment` records are the audit trail.
- **`whilesmart/eloquent-customers`** / **`eloquent-organizations`** -- typical models that would implement `Vendor`.

Config
------

[](#config)

`php artisan vendor:publish --tag=expenses-config`:

```
return [
    'register_routes' => env('EXPENSES_REGISTER_ROUTES', true),
    'route_prefix' => env('EXPENSES_ROUTE_PREFIX', 'api'),
    'route_middleware' => ['api', 'auth:sanctum'],
    'table' => env('EXPENSES_TABLE', 'expenses'),
];
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance92

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

2

Last Release

40d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1ca6f6e01ecbfe6640ff410c4f0321054fb48d05a5f843c2b89887b90369bcd?d=identicon)[whilesmart](/maintainers/whilesmart)

---

Top Contributors

[![nfebe](https://avatars.githubusercontent.com/u/14317775?v=4)](https://github.com/nfebe "nfebe (9 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/whilesmart-eloquent-expenses/health.svg)

```
[![Health](https://phpackages.com/badges/whilesmart-eloquent-expenses/health.svg)](https://phpackages.com/packages/whilesmart-eloquent-expenses)
```

###  Alternatives

[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

10.2k4.0k](/packages/leantime-leantime)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k8](/packages/statamic-rad-pack-runway)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3518.3k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

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