Esempio n. 1
0
 /**
  * @param array $attributes
  */
 public function saveFromArray(array $attributes = array())
 {
     $this->model->customer_id = $attributes['customer_id'];
     if (!isset($attributes['orders_status_id'])) {
         $ordersStatus = Models\OrdersStatus::where('default', 1)->first();
         $this->model->orders_status_id = $ordersStatus->id;
     } else {
         $this->model->orders_status_id = $attributes['orders_status_id'];
     }
     $this->model->total = $attributes['total'];
     $this->model->comment = $attributes['comment'];
     $this->model->save();
     $this->model->items()->delete();
     foreach ($attributes['items'] as $oredersItem) {
         $item = new Models\OrdersItem();
         $item->order_id = $this->model->id;
         $item->photo_id = $oredersItem['photo_id'];
         $item->qty = $oredersItem['qty'];
         $item->format_id = $oredersItem['format_id'];
         $item->price_per_item = $oredersItem['price_per_item'];
         $item->save();
         foreach ($oredersItem['addons'] as $oredersItemsAddon) {
             if (isset($oredersItemsAddon['id']) && $oredersItemsAddon['id']) {
                 $addon = new Models\OrdersItemsAddon();
                 $addon->orders_item_id = $item->id;
                 $addon->addon_id = $oredersItemsAddon['id'];
                 $addon->qty = $oredersItemsAddon['qty'];
                 $addon->save();
             }
         }
     }
 }
 /**
  * @return array
  */
 public function getList()
 {
     $list = [];
     foreach (Models\OrdersStatus::all() as $status) {
         $list[$status->id] = $status->getName();
     }
     return $list;
 }
 /**
  * @SWG\Api(
  *   path="/orders_status/all",
  *   @SWG\Operation(
  *     nickname="Get all orders status",
  *     method="GET",
  *     summary="Find all orders status",
  *     notes="Returns all orders status",
  *     type="array",
  *     @SWG\Items("OrdersStatus"),
  *     authorizations={}
  *   )
  * )
  */
 public function all()
 {
     $statusCode = 200;
     $response = [];
     $ordersStatusModels = Models\OrdersStatus::all();
     foreach ($ordersStatusModels as $ordersStatusModel) {
         $ordersStatusView = new ModelViews\OrdersStatus($ordersStatusModel);
         $response[] = $ordersStatusView->get();
     }
     return \Response::json($response, $statusCode);
 }
Esempio n. 4
0
 /**
  * @return mixed
  */
 public static function getList()
 {
     $model = new Models\OrdersStatus();
     return $model->getRepository()->getList();
 }