{"id":51045271,"url":"https://github.com/whilesmartphp/eloquent-projects","last_synced_at":"2026-06-22T13:02:12.762Z","repository":{"id":357448753,"uuid":"1035191421","full_name":"whilesmartphp/eloquent-projects","owner":"whilesmartphp","description":"Polymorphic project and version management package for Laravel applications","archived":false,"fork":false,"pushed_at":"2026-05-12T19:41:58.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-12T21:27:51.764Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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":"2025-08-09T21:11:30.000Z","updated_at":"2026-05-12T19:41:28.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/whilesmartphp/eloquent-projects","commit_stats":null,"previous_names":["whilesmartphp/eloquent-projects"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/whilesmartphp/eloquent-projects","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-projects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-projects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-projects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-projects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilesmartphp","download_url":"https://codeload.github.com/whilesmartphp/eloquent-projects/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-projects/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:08.797Z","updated_at":"2026-06-22T13:02:12.757Z","avatar_url":"https://github.com/whilesmartphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eloquent Projects\n\nPolymorphic project container for Laravel applications.\n\n## Features\n\n- **Polymorphic Ownership**: Any model can own projects (workspaces, teams, orgs, users)\n- **Polymorphic Creator**: Track who or what created a project (users, agents, systems)\n- **Polymorphic Assignments**: Assign any entity to a project with a role\n- **Configurable Statuses**: Define project lifecycle states via database\n- **Archiving**: Soft archive/unarchive without deletion\n- **Lifecycle Events**: Hooks for created, updated, deleted, archived, assigned, etc.\n- **Middleware Hooks**: Before/after hooks on all controller actions\n- **Customizable Models**: Override Project, ProjectStatus, ProjectAssignment via config\n- **Child Model Support**: Any model can belong to a project via `BelongsToProject` trait\n- **Laravel 10+, 11+, 12+ Support**\n\n## Installation\n\n```bash\ncomposer require whilesmart/eloquent-projects\n```\n\n### Publish Configuration (Optional)\n\n```bash\nphp artisan vendor:publish --tag=projects-config\n```\n\n### Run Migrations\n\n```bash\nphp artisan migrate\n```\n\n## Quick Start\n\n### Owning Projects\n\nAdd the `HasProjects` trait to any model that should own projects:\n\n```php\nuse Whilesmart\\Projects\\Traits\\HasProjects;\n\nclass Workspace extends Model\n{\n    use HasProjects;\n}\n```\n\n```php\n$workspace-\u003ecreateProject('My Design', $user);\n$workspace-\u003ecreateProject('Campaign Q2', $aiAgent, 'Q2 marketing assets');\n$workspace-\u003eprojects; // all projects owned by this workspace\n```\n\n### Child Models\n\nAdd `BelongsToProject` to models that live inside a project:\n\n```php\nuse Whilesmart\\Projects\\Traits\\BelongsToProject;\n\nclass DesignVersion extends Model\n{\n    use BelongsToProject;\n}\n```\n\n```php\n$version-\u003eproject;                           // parent project\nDesignVersion::forProject($projectId)-\u003eget(); // all versions for a project\n```\n\n### Assignments\n\nAssign any entity (user, agent, team) to a project with a role:\n\n```php\nuse Whilesmart\\Projects\\Traits\\AssignableToProject;\n\nclass User extends Model\n{\n    use AssignableToProject;\n}\n```\n\n```php\n// Assign\n$project-\u003eassign($user, 'editor');\n$project-\u003eassign($aiAgent, 'generator', $admin);\n$project-\u003eassign($team, 'stakeholder', null, ['notify' =\u003e true]);\n\n// Query\n$project-\u003eassignments;                    // all assignments\n$project-\u003eassignees('editor')-\u003eget();     // editors only\n$project-\u003eisAssigned($user, 'editor');    // true\n\n// From the assignable side\n$user-\u003eassignedProjects()-\u003eget();            // all projects\n$user-\u003eassignedProjects('editor')-\u003eget();    // projects where user is editor\n$user-\u003eisAssignedToProject($project);        // true\n\n// Unassign\n$project-\u003eunassign($user, 'editor');   // remove specific role\n$project-\u003eunassign($user);            // remove all roles\n```\n\n### Statuses\n\n```php\nuse Whilesmart\\Projects\\Models\\ProjectStatus;\n\nProjectStatus::create(['name' =\u003e 'Active', 'slug' =\u003e 'active', 'color' =\u003e '#22c55e']);\nProjectStatus::create(['name' =\u003e 'Paused', 'slug' =\u003e 'paused', 'color' =\u003e '#f59e0b']);\nProjectStatus::create(['name' =\u003e 'Completed', 'slug' =\u003e 'completed', 'color' =\u003e '#3b82f6']);\n\n$project-\u003eupdate(['status_id' =\u003e $status-\u003eid]);\n$project-\u003estatus-\u003ename; // \"Active\"\n\nProject::withStatus('active')-\u003eget();\n```\n\n### Archiving\n\n```php\n$project-\u003earchive();\n$project-\u003eisArchived();  // true\n$project-\u003eunarchive();\n\nProject::active()-\u003eget();    // non-archived\nProject::archived()-\u003eget();  // archived only\n```\n\n### Metadata\n\n```php\n$project = Project::create([\n    'owner_type' =\u003e Workspace::class,\n    'owner_id' =\u003e $ws-\u003eid,\n    'title' =\u003e 'Campaign',\n    'metadata' =\u003e ['budget' =\u003e 5000, 'deadline' =\u003e '2026-04-01'],\n]);\n\n$project-\u003egetMetadata('budget');              // 5000\n$project-\u003egetMetadata('missing', 'default');  // 'default'\n$project-\u003esetMetadata('priority', 'high');\n$project-\u003esave();\n```\n\n## Events\n\n| Event | Fired when |\n|---|---|\n| `ProjectCreated` | Project is created |\n| `ProjectUpdated` | Project is updated |\n| `ProjectDeleted` | Project is deleted |\n| `ProjectArchived` | Project is archived |\n| `ProjectUnarchived` | Project is unarchived |\n| `ProjectAssigned` | Entity is assigned to a project |\n| `ProjectUnassigned` | Entity is unassigned from a project |\n\n## Configuration\n\n```php\n// config/projects.php\nreturn [\n    'models' =\u003e [\n        'project' =\u003e \\Whilesmart\\Projects\\Models\\Project::class,\n        'project_status' =\u003e \\Whilesmart\\Projects\\Models\\ProjectStatus::class,\n        'project_assignment' =\u003e \\Whilesmart\\Projects\\Models\\ProjectAssignment::class,\n    ],\n\n    'register_routes' =\u003e true,\n    'route_prefix' =\u003e '',\n    'route_middleware' =\u003e ['auth:sanctum'],\n\n    'middleware_hooks' =\u003e [],\n];\n```\n\n### Custom Models\n\n```php\nclass Project extends \\Whilesmart\\Projects\\Models\\Project\n{\n    // custom logic, relationships, scopes\n}\n```\n\n```php\n// config/projects.php\n'models' =\u003e [\n    'project' =\u003e App\\Models\\Project::class,\n],\n```\n\n### Middleware Hooks\n\n```php\nuse Whilesmart\\Projects\\Interfaces\\MiddlewareHookInterface;\n\nclass ProjectHook implements MiddlewareHookInterface\n{\n    public function before(Request $request, string $action): ?Request\n    {\n        return $request;\n    }\n\n    public function after(Request $request, JsonResponse $response, string $action): JsonResponse\n    {\n        return $response;\n    }\n}\n```\n\n## API Routes\n\n```\nGET    /projects                List projects (filter: ?owner_type=, ?owner_id=, ?status=, ?archived=)\nPOST   /projects                Create project\nGET    /projects/{id}           Show project\nPUT    /projects/{id}           Update project\nDELETE /projects/{id}           Delete project\nPOST   /projects/{id}/archive   Archive project\nPOST   /projects/{id}/unarchive Unarchive project\n```\n\n## Database Schema\n\n### projects\n\n| Column | Type | Description |\n|---|---|---|\n| owner_type / owner_id | morph | Polymorphic owner |\n| creator_type / creator_id | morph (nullable) | Polymorphic creator (immutable) |\n| status_id | FK (nullable) | References project_statuses |\n| title | string | Project title |\n| description | text (nullable) | Description |\n| thumbnail_url | string (nullable) | Preview image |\n| metadata | JSON (nullable) | Flexible data |\n| archived_at | timestamp (nullable) | Archive timestamp |\n\n### project_statuses\n\n| Column | Type | Description |\n|---|---|---|\n| name | string | Display name |\n| slug | string (unique) | Identifier |\n| description | string (nullable) | Description |\n| color | string (nullable) | Hex color |\n| sort_order | integer | Display ordering |\n\n### project_assignments\n\n| Column | Type | Description |\n|---|---|---|\n| project_id | FK | References projects |\n| assignable_type / assignable_id | morph | Entity assigned |\n| role | string | Assignment role |\n| assigned_by_type / assigned_by_id | morph (nullable) | Who assigned |\n| metadata | JSON (nullable) | Flexible data |\n\nUnique constraint: `(project_id, assignable_type, assignable_id, role)`\n\n## Testing\n\n```bash\nmake test       # Run tests via Docker\nmake pint       # Run code formatter\nmake check      # Run all checks (pint + tests)\n```\n\n## Requirements\n\n- PHP 8.2+\n- Laravel 10.0, 11.0, or 12.0\n\n## License\n\nMIT License\n\n## Credits\n\nDeveloped by the Whilesmart Team\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-projects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilesmartphp%2Feloquent-projects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-projects/lists"}