rockbuzz / lara-orders
Abstraction for order implementation
0.9.2
2021-08-03 19:08 UTC
Requires
- php: >=7.4
- rockbuzz/lara-utils: ^0.2.0
Requires (Dev)
- laravel/legacy-factories: ^1.0.4
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.0
README
Order management
Requirements
PHP >=7.4
Install
$ composer require rockbuzz/lara-orders
$ php artisan vendor:publish --provider="Rockbuzz\LaraOrders\ServiceProvider" --tag="migrations"
$ php artisan migrate
Add the HasOrder
trait to the template for which you will be ordering
Usage
use Rockbuzz\LaraOrders\Transaction; use Rockbuzz\LaraOrders\Models\Order; use Rockbuzz\LaraOrders\Models\OrderCoupon; use Rockbuzz\LaraOrders\Traits\HasOrder; class YourBuyer { use HasOrder }
$buyer->orders(): MorphMany; $buyer->createOrder(array $notes = []): Order; $buyer->orderById(int $id): ?Order; $buyer->orderByUuid(string $uuid): ?Order;
$order->buyer(): BelongsTo; $order->coupon(): BelongsTo; $order->applyCoupon(OrderCoupon $coupon); $order->items(): HasMany; $order->total; //98.99 $order->totalInCents; //9899 $order->totalWithCoupon; //88.99 $order->totalWithCouponInCents; //8899 $order->transactions(): HasMany;
- Events
Rockbuzz\LaraOrders\Events\OrderCreated::class Rockbuzz\LaraOrders\Events\OrderTransactionCreated::class Rockbuzz\LaraOrders\Events\CouponApplied::class
License
The Lara Orders is open-sourced software licensed under the MIT license.