unisharp/buyable
let laravel model buyable
2,084
3
| Install | |
|---|---|
composer require unisharp/buyable |
|
| Latest Version: | 0.0.9 |
| PHP: | ^7.0 |
| License: | MIT |
| Last Updated: | Sep 26, 2018 |
| Links: | GitHub · Packagist |
Maintainer: FreedomKnight
UniSharp Buyable
Let laravel model buyable
Installation
-
Install package
composer require unisharp/buyable dev-master -
Migrate tables
php artisan migrate
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
Related Packages
rinvex/laravel-categories
Rinvex Categories is a polymorphic Laravel package, for category management. You...
173,594
466
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 0.0.9 | ^7.0 | >5.5.0 | MIT | |
| 0.0.8 | ^7.0 | >5.5.0 | MIT | |
| 0.0.7 | ^7.0 | >5.5.0 | MIT | |
| 0.0.6 | ^7.0 | >5.5.0 | MIT | |
| 0.0.5 | ^7.0 | >5.5.0 | MIT | |
| 0.0.4 | ^7.0 | >5.5.0 | MIT | |
| 0.0.3 | ^7.0 | >5.5.0 | MIT | |
| 0.0.2 | ^7.0 | >5.5.0 | MIT | |
| 0.0.1 | ^7.0 | >5.5.0 | MIT |