{"id":51045333,"url":"https://github.com/whilesmartphp/eloquent-products","last_synced_at":"2026-06-22T13:02:31.596Z","repository":{"id":353788612,"uuid":"1203563911","full_name":"whilesmartphp/eloquent-products","owner":"whilesmartphp","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-11T11:13:22.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-06-11T12:06:46.822Z","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":null,"contributing":null,"funding":null,"license":null,"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-04-07T06:42:26.000Z","updated_at":"2026-06-11T11:09:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/whilesmartphp/eloquent-products","commit_stats":null,"previous_names":["whilesmartphp/eloquent-products"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/whilesmartphp/eloquent-products","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-products","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-products/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-products/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-products/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilesmartphp","download_url":"https://codeload.github.com/whilesmartphp/eloquent-products/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Feloquent-products/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.699Z","updated_at":"2026-06-22T13:02:31.586Z","avatar_url":"https://github.com/whilesmartphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# whilesmart/eloquent-products\n\nPolymorphic product / service catalog for Laravel applications. Implements `Whilesmart\\Invoices\\Contracts\\Invoiceable` so every product can be referenced as a line item by `whilesmart/eloquent-invoices`.\n\n## Install\n\n```bash\ncomposer require whilesmart/eloquent-products\nphp artisan migrate\n```\n\n`whilesmart/eloquent-invoices` is a hard dependency — composer pulls it in automatically because every Product implements its `Invoiceable` contract.\n\n## Use\n\nAdd `HasProducts` to any model that should own a catalog (Workspace, Organization, User, …):\n\n```php\nuse Whilesmart\\Products\\Traits\\HasProducts;\n\nclass Workspace extends Model\n{\n    use HasProducts;\n}\n```\n\nCreate products and services:\n\n```php\n$workspace-\u003eproducts()-\u003ecreate([\n    'type'                =\u003e 'product',\n    'sku'                 =\u003e 'SHN-30YR',\n    'name'                =\u003e '30-year asphalt shingles',\n    'default_unit'        =\u003e 'bundle',\n    'default_price_cents' =\u003e 4200,\n    'currency'            =\u003e 'USD',\n]);\n\n$workspace-\u003eproducts()-\u003ecreate([\n    'type'                =\u003e 'service',\n    'sku'                 =\u003e 'LBR-ROOF',\n    'name'                =\u003e 'Roofing labour',\n    'default_unit'        =\u003e 'hour',\n    'default_price_cents' =\u003e 7500,\n]);\n```\n\nThen drop them onto an invoice without retyping anything:\n\n```php\n$invoice-\u003elineItems()-\u003ecreate([\n    'invoiceable_type' =\u003e Product::class,\n    'invoiceable_id'   =\u003e $shingles-\u003eid,\n    'quantity'         =\u003e 12,\n]);\n```\n\nThe line item gets `description`, `default_unit`, and `default_price_cents` snapshotted from the product at create time.\n\n## Endpoints\n\n| Verb | Path | Notes |\n|---|---|---|\n| `GET` | `/api/products` | List, filter by `owner_type`+`owner_id`, `type`, `category`, `is_active`, search via `?q=` |\n| `POST` | `/api/products` | Create |\n| `GET` | `/api/products/{id}` | Show |\n| `PUT` | `/api/products/{id}` | Update |\n| `DELETE` | `/api/products/{id}` | Soft delete |\n\n## Type enum\n\n`Whilesmart\\Products\\Enums\\ProductType`: `product` (physical / unit-priced) or `service` (time / rate-priced). Same model, single table.\n\n## Schema\n\n`products` table:\n\n| column | type |\n|---|---|\n| id | bigint |\n| owner_type / owner_id | morphs |\n| type | string (enum) |\n| sku | nullable string, unique per owner |\n| name | string |\n| description | text |\n| default_unit | nullable string |\n| default_price_cents / default_cost_cents | bigint |\n| default_tax_rate | decimal(6,4) nullable |\n| currency | char(3) |\n| category | nullable string |\n| is_active | boolean |\n| metadata | json |\n| timestamps + soft deletes | |\n\n## Scope\n\nThis package does **one thing**: store the reusable definition of a product or service. Adjacent concerns live in their own packages:\n\n- Inventory levels / stock counts → `whilesmart/eloquent-inventory` (later)\n- Multi-tier / multi-currency price lists → `whilesmart/eloquent-pricing` (later)\n- Bundles / kits → on top of the same products table, later\n\n## Config\n\nPublish with `php artisan vendor:publish --tag=products-config`. Override `register_routes`, `route_prefix`, `route_middleware`, and `table` via env or the published config file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-products","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilesmartphp%2Feloquent-products","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Feloquent-products/lists"}