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.

05PHP

Since Apr 24Pushed 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 1w ago

READMEChangelogDependenciesVersions (3)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

22

—

LowBetter than 22% of packages

Maintenance60

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### 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 (3 commits)")

### 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

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8361.6M87](/packages/propel-propel1)[mpociot/laravel-composite-key

Support composite keys in your laravel app.

3544.8k1](/packages/mpociot-laravel-composite-key)

PHPackages © 2026

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