{"id":51045330,"url":"https://github.com/whilesmartphp/eloquent-employees","last_synced_at":"2026-06-22T13:02:31.328Z","repository":{"id":364826831,"uuid":"1269286071","full_name":"whilesmartphp/eloquent-employees","owner":"whilesmartphp","description":"Polymorphic employee records for Laravel, with optional links to authenticated users.","archived":false,"fork":false,"pushed_at":"2026-06-14T16:12:39.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-06-14T18:08:06.460Z","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":"mit","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":"LICENSE","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-06-14T14:25:56.000Z","updated_at":"2026-06-14T16:12:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/whilesmartphp/eloquent-employees","commit_stats":null,"previous_names":["whilesmartphp/eloquent-employees"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/whilesmartphp/eloquent-employees","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-employees","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-employees/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-employees/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-employees/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilesmartphp","download_url":"https://codeload.github.com/whilesmartphp/eloquent-employees/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-employees/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:02:30.500Z","updated_at":"2026-06-22T13:02:31.321Z","avatar_url":"https://github.com/whilesmartphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eloquent Employees\n\nPolymorphic employee records for Laravel. An employee belongs to a business (workspace / organisation) and\nmay optionally be linked to an authenticated user. People who never log in (payroll-only staff, contractors)\nare first-class: they exist as records and can be referenced in expenses, payroll, and reports without an\naccount.\n\n## Install\n\n```\ncomposer require whilesmart/eloquent-employees\nphp artisan migrate\n```\n\nAttach `HasEmployees` to the model that employs people (workspace / organisation):\n\n```php\nuse Whilesmart\\Employees\\Traits\\HasEmployees;\n\nclass Workspace extends Model\n{\n    use HasEmployees;\n}\n```\n\n## Data model\n\nAn employee is a party record scoped to its owner, distinct from the auth user:\n\n- **`owner`** -- the employing business, polymorphic (`owner_type` + `owner_id`), required.\n- **`user_id`** -- optional link to an authenticated user. Null for people without a login.\n- **`reporting_to_id`** -- optional self-reference to the employee's manager.\n\nOther fields: `first_name`, `last_name`, `email`, `phone`, `title`, `department`, `status`\n(`active | inactive | on_leave | terminated`), `employment_type` (`full_time | part_time | contractor`),\n`start_date`, `end_date`, `metadata`. A read-only `name` accessor returns the full name. Host-specific\nextras (such as an avatar) live in the `metadata` bag, not on the core table.\n\n`email` is unique per owner, not globally. Employees use the `HasRoles` trait from\n`whilesmart/eloquent-roles`, so role bundles (accountant, manager, ...) can be assigned in a workspace\ncontext.\n\n## Routes\n\nRegisters an `apiResource` plus a link action at the configured prefix (default `api`, middleware\n`['api', 'auth:sanctum']`):\n\n```\nGET    /api/employees\nPOST   /api/employees\nGET    /api/employees/{employee}\nPUT    /api/employees/{employee}\nDELETE /api/employees/{employee}\nPOST   /api/employees/{employee}/link-user\n```\n\n`link-user` attaches a `user_id` to an employee and fires `EmployeeLinkedToUser`; the host app listens to\nthat event to add the user to the workspace, send an invite, or grant a default role bundle.\n\nIndex filters: `owner_type`, `owner_id`, `status`, `employment_type`, `department`, `has_login`, `q`,\n`per_page`.\n\n## Authorization\n\nEvery action is scoped through `whilesmart/eloquent-owner-access`. The host app binds an `OwnerAuthorizer`;\n`index` is constrained to accessible owners and `show`/`update`/`destroy`/`link-user` authorize the record's\nowner. The package never decides tenancy itself.\n\n## Relationship to other packages\n\n- **`whilesmart/eloquent-workspaces`** -- workspace *members* are auth users; employees are people, with or\n  without a login. Link the two via `user_id`.\n- **`whilesmart/eloquent-roles`** -- employees are assignable role holders; capability bundles live here.\n- **`whilesmart/eloquent-expenses`** -- attribute who incurred or approved an expense to an employee.\n\n## Config\n\n`php artisan vendor:publish --tag=employees-config`:\n\n```php\nreturn [\n    'register_routes' =\u003e env('EMPLOYEES_REGISTER_ROUTES', true),\n    'route_prefix' =\u003e env('EMPLOYEES_ROUTE_PREFIX', 'api'),\n    'route_middleware' =\u003e ['api', 'auth:sanctum'],\n    'table' =\u003e env('EMPLOYEES_TABLE', 'employees'),\n    'user_model' =\u003e env('EMPLOYEES_USER_MODEL', 'App\\\\Models\\\\User'),\n];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-employees","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilesmartphp%2Feloquent-employees","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-employees/lists"}