예제 #1
0
 public function order_custom($params = [])
 {
     $parts = Part::get_parts();
     $order = Record::allow($params, array_keys($parts));
     $key = Quote::get_unique_key([]);
     $model['`key`'] = $key;
     $fields = ['company', 'address', 'country', 'billing_name', 'billing_email', 'billing_phone', 'technical_name', 'technical_email', 'discount', 'discount_desc'];
     $model += Record::allow($params, $fields);
     $quote = Quote::create($model);
     $total = 0;
     foreach ($order as $name => $value) {
         if ($value) {
             $model = ['quote_id' => $quote['id'], 'part' => $name, 'override' => null, 'quantity' => $value];
             QuoteItem::create($model);
         }
     }
     return Render::json(['key' => $key]);
 }