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. unisharp/buyable

ActiveLibrary

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 2d 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 60% 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

2976d 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://www.gravatar.com/avatar/9a2fc2455de09cd6a0cc4fdd640be6a1a2876818531c0a09abcf578528c37b07?d=identicon)[CatheCat](/maintainers/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

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M253](/packages/cviebrock-eloquent-sluggable)[genealabs/laravel-model-caching

Automatic caching for Eloquent models.

2.4k4.8M26](/packages/genealabs-laravel-model-caching)[cmgmyr/messenger

Simple user messaging tool for Laravel

2.6k2.4M6](/packages/cmgmyr-messenger)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[mikebronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k127.1k1](/packages/mikebronner-laravel-model-caching)

PHPackages © 2026

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