Skip to content

Commit

Permalink
Added status configuration files
Browse files Browse the repository at this point in the history
Fill up completed_at upon status "COMPLETE"
  • Loading branch information
Trexology committed Dec 4, 2015
1 parent faa115f commit 8313ffc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and under "aliases" add:

'Order' => 'Trexology\LaravelOrder\Facades\Order',

Edit additional settings at config/order.php


# Usage

Expand Down
4 changes: 2 additions & 2 deletions src/LaravelOrderServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function registerAssets()
], 'migrations');

$this->publishes([
__DIR__.'/../config/config.php' => config_path('order.php')
__DIR__.'/config/config.php' => config_path('order.php')
], 'config');
}

Expand All @@ -39,7 +39,7 @@ protected function registerServices() {
return new Model\Order;
});

$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'order');
$this->mergeConfigFrom(__DIR__ . '/config/config.php', 'order');
}

/**
Expand Down
23 changes: 3 additions & 20 deletions src/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ class Order extends Model

protected $guarded = ['id', 'created_at', 'updated_at'];

// /**
// * 订单状态的定义.
// *
// * @var string
// */
public $INIT = config('order.init');
public $OBLIGATION = 'obligation';
public $PROCESSING = 'processing';
public $COMPLETE = config('order.complete');


/**
* Create an Order
*
Expand All @@ -34,7 +23,7 @@ public function order($user_id, $data = null, $draft = FALSE)
$order = new self();

$order->user_id = $user_id;
$order->state = $this->INIT;
$order->state = config("order.init");
$order->items_number = 0;
$order->items_total = 0;

Expand Down Expand Up @@ -182,20 +171,15 @@ public function removeItem($order_id, $item_id)
*/
public function updateStatus($order_id, $status)
{
// if (!($status == $this->INIT || $status == $this->COMPLETE
// || $status == $this->OBLIGATION || $status == $this->PROCESSING)) {
// return false;
// }

$order = $this->getOrder($order_id);

if (!$order) {
return false;
}

if ($status == $this->COMPLETE) {
if ($status == config("order.complete")) {
//Mark order as completed
$order->completed_at = now();
$order->completed_at = date("Y-m-d H:i:s");
}

$order->state = $status;
Expand Down Expand Up @@ -270,7 +254,6 @@ public function total($order_id)
}
}


return $total;
}

Expand Down

0 comments on commit 8313ffc

Please sign in to comment.