PHP code example of rockbuzz / lara-orders

1. Go to this page and download the library: Download rockbuzz/lara-orders library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rockbuzz / lara-orders example snippets


$ php artisan vendor:publish --provider="Rockbuzz\LaraOrders\ServiceProvider" --tag="migrations"

$ php artisan migrate

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;

Rockbuzz\LaraOrders\Events\OrderCreated::class
Rockbuzz\LaraOrders\Events\OrderTransactionCreated::class
Rockbuzz\LaraOrders\Events\CouponApplied::class