{"id":19706727,"url":"https://github.com/unisharp/buyable","last_synced_at":"2025-04-29T16:33:39.668Z","repository":{"id":57075564,"uuid":"124021733","full_name":"UniSharp/buyable","owner":"UniSharp","description":null,"archived":false,"fork":false,"pushed_at":"2018-09-26T04:27:10.000Z","size":50,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-05T18:12:21.228Z","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/UniSharp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-06T04:41:38.000Z","updated_at":"2022-03-02T05:46:25.000Z","dependencies_parsed_at":"2022-08-24T13:00:30.656Z","dependency_job_id":null,"html_url":"https://github.com/UniSharp/buyable","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fbuyable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fbuyable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fbuyable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fbuyable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UniSharp","download_url":"https://codeload.github.com/UniSharp/buyable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251540546,"owners_count":21605928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-11T21:36:41.169Z","updated_at":"2025-04-29T16:33:34.639Z","avatar_url":"https://github.com/UniSharp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UniSharp Buyable\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nLet laravel model buyable\n\n## Installation\n\n- Install package\n\n    ```composer require unisharp/buyable dev-master```\n\n- Migrate tables\n\n    ```php artisan migrate```\n\n## Usages\n\nUse trait in model\n\n```php\nnamespace App;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse UniSharp\\Buyable\\Traits;\n\nclass Product extends Model\n{\n    use Buyable;\n}\n```\n\nCreate model and model's specs at the same time\n\n```php\nProduct::create([\n    'name' =\u003e 'product A',\n    'spec' =\u003e 'Black',\n    'price' =\u003e 20,\n    'stock' =\u003e 5,\n    'sku' =\u003e 'B-1',\n    'sold_qty' =\u003e 2\n]);\n```\n\nChange one of model's spec\n\n```php\n$product-\u003eprice = 1;\n$product-\u003estock = 1;\n$product-\u003esku = 'B-2';\n$product-\u003esold_qty = 2;\n$product-\u003esave();\n```\n\nSpecified one of model's specs\n\n```php\n$spec = Spec::where('name', 'Black')-\u003efirst();\n\n$product-\u003especify($spec);\n\n$product-\u003especify($spec-\u003eid);\n\n$product-\u003especify('Black');\n```\n\nGet all of model's specs\n\n```php\n$product-\u003especs\n```\n\n[ico-version]: https://img.shields.io/packagist/v/UniSharp/buyable.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/UniSharp/buyable/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/UniSharp/buyable.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/UniSharp/buyable.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/UniSharp/buyable.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/unisharp/buyable\n[link-travis]: https://travis-ci.org/UniSharp/buyable\n[link-scrutinizer]: https://scrutinizer-ci.com/g/UniSharp/buyable/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/UniSharp/buyable\n[link-downloads]: https://packagist.org/packages/UniSharp/buyable\n[link-author]: https://github.com/UniSharp\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisharp%2Fbuyable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funisharp%2Fbuyable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisharp%2Fbuyable/lists"}