PHPackages                             whilesmart/eloquent-employees - 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-employees

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

whilesmart/eloquent-employees
=============================

Polymorphic employee records for Laravel applications, with optional links to authenticated users.

1.0.0(1mo ago)031↓50%1[1 issues](https://github.com/whilesmartphp/eloquent-employees/issues)MITPHPPHP ^8.2

Since Jun 14Pushed 3w agoCompare

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

READMEChangelog (1)Dependencies (6)Versions (4)Used By (0)

Eloquent Employees
==================

[](#eloquent-employees)

Polymorphic employee records for Laravel. An employee belongs to a business (workspace / organisation) and may optionally be linked to an authenticated user. People who never log in (payroll-only staff, contractors) are first-class: they exist as records and can be referenced in expenses, payroll, and reports without an account.

Install
-------

[](#install)

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

```

Attach `HasEmployees` to the model that employs people (workspace / organisation):

```
use Whilesmart\Employees\Traits\HasEmployees;

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

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

[](#data-model)

An employee is a party record scoped to its owner, distinct from the auth user:

- **`owner`** -- the employing business, polymorphic (`owner_type` + `owner_id`), required.
- **`user_id`** -- optional link to an authenticated user. Null for people without a login.
- **`reporting_to_id`** -- optional self-reference to the employee's manager.

Other fields: `first_name`, `last_name`, `email`, `phone`, `title`, `department`, `status`(`active | inactive | on_leave | terminated`), `employment_type` (`full_time | part_time | contractor`), `start_date`, `end_date`, `metadata`. A read-only `name` accessor returns the full name. Host-specific extras (such as an avatar) live in the `metadata` bag, not on the core table.

`email` is unique per owner, not globally. Employees use the `HasRoles` trait from `whilesmart/eloquent-roles`, so role bundles (accountant, manager, ...) can be assigned in a workspace context.

Routes
------

[](#routes)

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

```
GET    /api/employees
POST   /api/employees
GET    /api/employees/{employee}
PUT    /api/employees/{employee}
DELETE /api/employees/{employee}
POST   /api/employees/{employee}/link-user

```

`link-user` attaches a `user_id` to an employee and fires `EmployeeLinkedToUser`; the host app listens to that event to add the user to the workspace, send an invite, or grant a default role bundle.

Index filters: `owner_type`, `owner_id`, `status`, `employment_type`, `department`, `has_login`, `q`, `per_page`.

Authorization
-------------

[](#authorization)

Every action is scoped through `whilesmart/eloquent-owner-access`. The host app binds an `OwnerAuthorizer`; `index` is constrained to accessible owners and `show`/`update`/`destroy`/`link-user` authorize the record's owner. The package never decides tenancy itself.

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

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

- **`whilesmart/eloquent-workspaces`** -- workspace *members* are auth users; employees are people, with or without a login. Link the two via `user_id`.
- **`whilesmart/eloquent-roles`** -- employees are assignable role holders; capability bundles live here.
- **`whilesmart/eloquent-expenses`** -- attribute who incurred or approved an expense to an employee.

Config
------

[](#config)

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

```
return [
    'register_routes' => env('EMPLOYEES_REGISTER_ROUTES', true),
    'route_prefix' => env('EMPLOYEES_ROUTE_PREFIX', 'api'),
    'route_middleware' => ['api', 'auth:sanctum'],
    'table' => env('EMPLOYEES_TABLE', 'employees'),
    'user_model' => env('EMPLOYEES_USER_MODEL', 'App\\Models\\User'),
];
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance93

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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

Unknown

Total

1

Last Release

46d 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 (3 commits)")[![kofimokome](https://avatars.githubusercontent.com/u/21100923?v=4)](https://github.com/kofimokome "kofimokome (1 commits)")[![Lantum-Brendan](https://avatars.githubusercontent.com/u/126294696?v=4)](https://github.com/Lantum-Brendan "Lantum-Brendan (1 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

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

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

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