PHPackages                             unisharp/buyable - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. unisharp/buyable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

unisharp/buyable
================

let laravel model buyable

0.0.9(8y ago)32.1kMITPHPPHP ^7.0

Since Mar 7Pushed 7y ago9 watchersCompare

[ Source](https://github.com/UniSharp/buyable)[ Packagist](https://packagist.org/packages/unisharp/buyable)[ Docs](https://github.com/UniSharp/buyable)[ RSS](/packages/unisharp-buyable/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (9)Dependencies (9)Versions (11)Used By (0)

UniSharp Buyable
================

[](#unisharp-buyable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/74a65e3da7a614dc146bfb5da3a9bc50ff8e492d5b05aea50c86fa40de05928e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f556e6953686172702f62757961626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/unisharp/buyable)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/30e79af3e24cde3fc05e9d27c36ec11f070720febbcccb1f4d79bd6649ee4d6b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f556e6953686172702f62757961626c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/UniSharp/buyable)[![Coverage Status](https://camo.githubusercontent.com/51bd62ee893158ad9f43e97f385b70671fd84bd7ff88b32a2d8a02af72cdef6d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f556e6953686172702f62757961626c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/UniSharp/buyable/code-structure)[![Quality Score](https://camo.githubusercontent.com/4db8aa7d3028b306c712d66441f96d0236ec2fb43b496d03d4cf63f8fd02793f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f556e6953686172702f62757961626c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/UniSharp/buyable)[![Total Downloads](https://camo.githubusercontent.com/5b010f9140a598608c254470db48d3c28de7df92ed439d7075860430c1452114/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f556e6953686172702f62757961626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/UniSharp/buyable)

Let laravel model buyable

Installation
------------

[](#installation)

- Install package

    `composer require unisharp/buyable dev-master`
- Migrate tables

    `php artisan migrate`

Usages
------

[](#usages)

Use trait in model

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use UniSharp\Buyable\Traits;

class Product extends Model
{
    use Buyable;
}
```

Create model and model's specs at the same time

```
Product::create([
    'name' => 'product A',
    'spec' => 'Black',
    'price' => 20,
    'stock' => 5,
    'sku' => 'B-1',
    'sold_qty' => 2
]);
```

Change one of model's spec

```
$product->price = 1;
$product->stock = 1;
$product->sku = 'B-2';
$product->sold_qty = 2;
$product->save();
```

Specified one of model's specs

```
$spec = Spec::where('name', 'Black')->first();

$product->specify($spec);

$product->specify($spec->id);

$product->specify('Black');
```

Get all of model's specs

```
$product->specs
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

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

Every ~1 days

Total

9

Last Release

3023d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1203922?v=4)[FreedomKnight](/maintainers/FreedomKnight)[@FreedomKnight](https://github.com/FreedomKnight)

![](https://avatars.githubusercontent.com/u/181350?v=4)[Youchen Lee (isacl)](/maintainers/youchenlee)[@youchenlee](https://github.com/youchenlee)

![](https://avatars.githubusercontent.com/u/14325344?v=4)[Catherine Chen](/maintainers/CatheCat)[@CatheCat](https://github.com/CatheCat)

---

Top Contributors

[![FreedomKnight](https://avatars.githubusercontent.com/u/1203922?v=4)](https://github.com/FreedomKnight "FreedomKnight (4 commits)")[![CatheCat](https://avatars.githubusercontent.com/u/14325344?v=4)](https://github.com/CatheCat "CatheCat (2 commits)")[![youchenlee](https://avatars.githubusercontent.com/u/181350?v=4)](https://github.com/youchenlee "youchenlee (1 commits)")

---

Tags

categoryUniSharp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/unisharp-buyable/health.svg)

```
[![Health](https://phpackages.com/badges/unisharp-buyable/health.svg)](https://phpackages.com/packages/unisharp-buyable)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
