omerbaflah / orders-laravel

Manage your orders with events and notifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Laravel Orders

This is a package to handle the orders in your Laravel application, you can create, update and delete your orders with suitable events. Also you can manage the order lifecycle from being initiated to the completed.

Features

  1. Create and Manage your orders easily
  2. See Orders Reports and its Customers
  3. Fire events within order lifecycle

You can start from the issues page to work on the feature which you prefer.

Table of Contents

Installation

composer require mgamal/laravel-orders

Optionally, you can publish the config file with:

php artisan vendor:publish --tag=config --provider="MG\LaravelOrder\OrderServiceProvider"

Usage

Manage Orders

  • Create Order
// Create Order
Order::create(OrderStatus status)
    ->withUser($user)
    ->withItems(...$items)
  • Update Order
// Update Order Status
$order->updateStatus(OrderStatus status)

// Update Order Items
$order->updateItems(...$items)
  • Listing Order(s)
// Get orders within specific period
Order::within(...$period);

// Get user orders.
Order::withUser($userOrUserId); 

//Get order with specific status
Order::withStatus($status);

Order Status

enum OrderStatus
{
    case Initiated;
    case InProgress;
    case Completed;
    case Failed;
}

Events

Order::statusUpdated(function (Order $order) {
    // Do your work here!
});

Testing

Running tests can be done either through composer, or directly calling the PHPUnit binary.

$ vendor/bin/phpunit test

License

The MIT License (MIT). Please see License File for more information.

About

Manage your orders with events and notifications

License:MIT License


Languages

Language:PHP 100.0%