rockbuzz/lara-orders

Abstraction for order implementation

0.9.2 2021-08-03 19:08 UTC

This package is auto-updated.

Last update: 2024-10-29 06:00:22 UTC


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.