2017 © Pedro Peláez
 

library laravel-order

Order for Laravel Application.

image

trexology/laravel-order

Order for Laravel Application.

  • Tuesday, August 2, 2016
  • by trexology
  • Repository
  • 3 Watchers
  • 8 Stars
  • 110 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 10 Versions
  • 1 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

laravel-order

Basic Ordering Package for Laravel 5+, (*2)

Installation

composer require trexology/laravel-order:2.*

After installation,go to config/app.php under providers section to add the following:, (*3)

Trexology\LaravelOrder\LaravelOrderServiceProvider::class

and under "aliases" add:, (*4)

'Order'     => Trexology\LaravelOrder\Facades\OrderFacade::class

publish the migration and config files with the commands:, (*5)

php artisan vendor:publish

Edit additional settings at config/order.php, (*6)

    return [

        /*
        |--------------------------------------------------------------------------
        | Order Status Name
        |--------------------------------------------------------------------------
        | Customize the status name recorded
        |
        */

        'init' => "init",
        'complete' => "complete",

        'ignoredFields' => []

    ];

Upgrade Guide from 1.*

• This package uses VentureCraft/revisionable to track order changes, (*7)

• Remove the old migration file '2015_12_02_150448_create_orderLogs_table.php', (*8)

• Column line_item_id in Orderitems table has been changed from integer to string for greater flexibility (version 1 user have to change the column type manually), (*9)

Usage

Create a new order

Order Order::order(int $user_id, array $data = null, bool $draft = FALSE), (*10)

    $data = [
        //Custom fields
        'cust_first_name' => $cust->first_name,
        'cust_last_name' => $cust->last_name
    ];

    $order = Order::order($cust->id, $data);

Add item to Order

Order Order::addItem(Order $order, Model $object, double $price, int $quantity, array $data = null, double $vat = 0);, (*11)

    $data = [
      'description' => "My item descriptions",
      'currency' => "SGD"
    ];
    $order = Order::addItem($order, $object, 25.5, 2, $data, 7);

Add item to Order (Non Eloquent Style)

Order Order::addItemManual(Order $order, string $object_id, string $object_type, double $price, int $quantity, array $data = null, double $vat = 0), (*12)

    $data = [
      'description' => "My item descriptions",
      'currency' => "SGD"
    ];
    $order = Order::addItem($order, 22, "App\Model\Object", 25.5, 2, $data, 7);

Batch Adding item to Order

Order Order::batchAddItems(Order $order, array $order_Items), (*13)

    $order_Items = [
        [
            "description" => "Some Description",
            "currency" => "USD",
            "line_item_id" => 1,
            "line_item_type" => "App\\Models\\Package",
            "price" => 1802,
            "quantity" => 1,
            "vat" => 0,
        ],
        [
            "description" => "Some Description",
            "currency" => "USD",
            "line_item_id" => 1,
            "line_item_type" => "App\\Models\\Package",
            "price" => 1802,
            "quantity" => 1,
            "vat" => 0,
        ]
    ];
    $order = Order::batchAddItems($order, $order_Items);

Get an order

    Order Order::getOrder(int $order_id);

Get user's orders

    Collection Order::getUserOrders(int $user_id);

Update Order Status

    boolean Order::updateStatus(int $order_id, string $status);

Delete an Order

    boolean Order::deleteOrder(int $order_id);

Update Order quantity

    OrderItem Order::updateQty(int $item_id, int qty);

Calculate an Order total amount

    float Order::total(Order $order);

Calculate an Order total item count

    int Order::count(Order $order);

The Versions

01/03 2016
12/02 2016

v1.3.2

1.3.2.0

Order for Laravel Application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar trexology

laravel order

18/01 2016

v1.3.1

1.3.1.0

Order for Laravel Application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar trexology

laravel order

22/12 2015

v1.2.0

1.2.0.0

Order for Laravel Application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar trexology

laravel order

04/12 2015

v1.1.0

1.1.0.0

Order for Laravel Application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar trexology

laravel order

02/12 2015

v1.0.0

1.0.0.0

Order for Laravel Application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar trexology

laravel order