소스 검색

Place orders by traversing suppliers

master
Immanuel Onyeka 3 년 전
부모
커밋
6648c72d53
1개의 변경된 파일26개의 추가작업 그리고 2개의 파일을 삭제
  1. +26
    -2
      app/Http/Controllers/Supply.php

+ 26
- 2
app/Http/Controllers/Supply.php 파일 보기

@@ -61,6 +61,7 @@ class Supply extends Controller
}
}

//Fulfills an order with only the primary supplier of it's service
public static function fulfill($order) {
if (gettype($order) == 'integer') {
$order = Order::find($order);
@@ -69,16 +70,39 @@ class Supply extends Controller
return Supply::orderPrimary($order);
}

public static function fulfillAny($order) {
//Fulfills an order with the first available supplier it finds. It returns
//false if none could be found and the refreshed order model otherwise.
public static function fulfillWithAny($order) {
if (gettype($order) == 'integer') {
$order = Order::find($order);
}
if (Supply::orderPrimary($order)) {
return $order->refresh();
};

$suppliers = $order->service->suppliers;

foreach ($suppliers as $s) {
switch ($s->supplier) {
case 'smmkings':
if (Supply::orderSmmkings($order, $s)){
return $order->refresh();
}
break;
case 'smmworld':
if (Supply::orderSmmkings($order, $s)){
return $order->refresh();
}
break;
}
}

return false;
}

//Fulfills an order with only the primary supplier of it's service
public static function orderPrimary($order) {
if (gettype($order) == 'integer') {
$order = Order::find($order);


불러오는 중...
취소
저장