ソースを参照

added quantity of added products to order

Alexander Musikhin 8 ヶ月 前
コミット
3bd72bb325

+ 7 - 2
app/Http/Controllers/OrderController.php

@@ -170,6 +170,7 @@ class OrderController extends Controller
         $data = $request->validated();
 
         $products = $request->validated('products');
+        $quantities = $request->validated('quantity');
 
         unset($data['products']);
 
@@ -180,9 +181,13 @@ class OrderController extends Controller
         } else {
             $order = Order::query()->create($data);
         }
-        if($products) {
+
+        if($products && $quantities) {
             $order->products()->detach();
-            $order->products()->attach($products);
+            foreach ($products as $key => $product) {
+                if($quantities[$key] == 0) continue;
+                $order->products()->attach($product, ['quantity' => $quantities[$key]]);
+            }
         }
 
         return redirect()->route('order.index');

+ 1 - 0
app/Http/Requests/Order/StoreOrderRequest.php

@@ -37,6 +37,7 @@ class StoreOrderRequest extends FormRequest
             'tg_group_name'     => 'nullable|string',
             'tg_group_link'     => 'nullable|string',
             'products'          => 'nullable|array',
+            'quantity'          => 'nullable|array',
         ];
     }
 }

+ 1 - 1
app/Models/Order.php

@@ -34,7 +34,7 @@ class Order extends Model
      */
     public function products(): BelongsToMany
     {
-        return $this->belongsToMany(Product::class, 'order_product', 'order_id', 'product_id');
+        return $this->belongsToMany(Product::class, 'order_product')->withPivot('quantity');
     }
 
     public function user(): BelongsTo

+ 58 - 58
bpmn.drawio

@@ -1,179 +1,179 @@
-<mxfile host="drawio-plugin" modified="2025-03-30T19:53:06.940Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" etag="5R6zNRTsdaPrHyTNHlzS" version="22.1.22" type="embed">
+<mxfile host="drawio-plugin" modified="2025-03-31T17:02:55.696Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" etag="RxFHjdKMyroV_aJsYAU-" version="22.1.22" type="embed">
   <diagram id="23iRSUPoRavnBvh4doch" name="Page-1">
-    <mxGraphModel dx="1352" dy="770" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
+    <mxGraphModel dx="1112" dy="770" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
       <root>
         <mxCell id="0" />
         <mxCell id="1" parent="0" />
-        <mxCell id="4" value="Менеджер" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
+        <mxCell id="4" value="Менеджер" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
           <mxGeometry y="80" width="1200" height="280" as="geometry">
             <mxRectangle y="80" width="40" height="90" as="alternateBounds" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="2" value="новый заказ" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="4">
+        <mxCell id="2" value="новый заказ" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="4" vertex="1">
           <mxGeometry x="60" y="10" width="80" height="80" as="geometry" />
         </mxCell>
-        <mxCell id="3" value="согласование&lt;br&gt;товаров, подтверждение" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="4">
+        <mxCell id="3" value="согласование&lt;br&gt;товаров, подтверждение" style="rounded=1;whiteSpace=wrap;html=1;" parent="4" vertex="1">
           <mxGeometry x="40" y="110" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="5" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="4" source="2" target="3">
+        <mxCell id="5" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="4" source="2" target="3" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="290" y="350" as="sourcePoint" />
             <mxPoint x="340" y="300" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="14" value="приход товара на склад" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="4">
+        <mxCell id="14" value="приход товара на склад" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="4" vertex="1">
           <mxGeometry x="200" y="10" width="80" height="80" as="geometry" />
         </mxCell>
-        <mxCell id="15" value="Заведение товара (пометка о поступлении)" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="4">
-          <mxGeometry x="180" y="110" width="120" height="60" as="geometry" />
+        <mxCell id="15" value="Заведение товара (пометка о поступлении)" style="rounded=1;whiteSpace=wrap;html=1;" parent="4" vertex="1">
+          <mxGeometry x="180" y="160" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="17" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="4" source="14" target="15">
+        <mxCell id="17" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="4" source="14" target="15" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="370" y="370" as="sourcePoint" />
             <mxPoint x="420" y="320" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="19" value="укомплектование заказа товарами со склада" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="4">
+        <mxCell id="19" value="укомплектование заказа товарами со склада" style="rounded=1;whiteSpace=wrap;html=1;" parent="4" vertex="1">
           <mxGeometry x="320" y="20" width="120" height="70" as="geometry" />
         </mxCell>
-        <mxCell id="37" value="Сообщение об ошибке" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" vertex="1" parent="4">
+        <mxCell id="37" value="Сообщение об ошибке" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="4" vertex="1">
           <mxGeometry x="400" y="210" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="40" value="Ссылка&lt;br&gt;на&amp;nbsp;пакет &lt;br&gt;документов" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" vertex="1" parent="4">
+        <mxCell id="40" value="Ссылка&lt;br&gt;на&amp;nbsp;пакет &lt;br&gt;документов" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="4" vertex="1">
           <mxGeometry x="400" y="140" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="45" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="4" source="42" target="44">
+        <mxCell id="45" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="4" source="42" target="44" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="42" value="Выполнен монтаж" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="4">
+        <mxCell id="42" value="Выполнен монтаж" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="4" vertex="1">
           <mxGeometry x="580" y="10" width="80" height="80" as="geometry" />
         </mxCell>
-        <mxCell id="44" value="Нажимаем в заказе кнопку &quot;Заказ готов&quot;" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="4">
+        <mxCell id="44" value="Нажимаем в заказе кнопку &quot;Заказ готов&quot;" style="rounded=1;whiteSpace=wrap;html=1;" parent="4" vertex="1">
           <mxGeometry x="560" y="110" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="50" value="Ссылка&lt;br&gt;на пакет документов" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" vertex="1" parent="4">
+        <mxCell id="50" value="Ссылка&lt;br&gt;на пакет документов" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="4" vertex="1">
           <mxGeometry x="630" y="210" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="53" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" edge="1" parent="4">
+        <mxCell id="53" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" parent="4" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="310" y="600" as="sourcePoint" />
             <mxPoint x="310" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="54" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" edge="1" parent="4">
+        <mxCell id="54" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" parent="4" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="550" y="600" as="sourcePoint" />
             <mxPoint x="550" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="55" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" edge="1" parent="4">
+        <mxCell id="55" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" parent="4" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="770" y="600" as="sourcePoint" />
             <mxPoint x="770" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="58" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="4" source="56" target="57">
+        <mxCell id="58" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="4" source="56" target="57" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="56" value="Претензия" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="4">
+        <mxCell id="56" value="Претензия" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="4" vertex="1">
           <mxGeometry x="810" y="15" width="80" height="80" as="geometry" />
         </mxCell>
-        <mxCell id="57" value="Создание рекламации" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="4">
+        <mxCell id="57" value="Создание рекламации" style="rounded=1;whiteSpace=wrap;html=1;" parent="4" vertex="1">
           <mxGeometry x="790" y="185" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="61" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" edge="1" parent="4">
+        <mxCell id="61" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" parent="4" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="920" y="600" as="sourcePoint" />
             <mxPoint x="920" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="63" value="Претензия исправлена" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="4">
+        <mxCell id="63" value="Претензия исправлена" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="4" vertex="1">
           <mxGeometry x="950" y="15" width="80" height="80" as="geometry" />
         </mxCell>
-        <mxCell id="64" value="Закрытие оекламации" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="4">
+        <mxCell id="64" value="Закрытие оекламации" style="rounded=1;whiteSpace=wrap;html=1;" parent="4" vertex="1">
           <mxGeometry x="930" y="185" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="62" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="4" source="63" target="64">
+        <mxCell id="62" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="4" source="63" target="64" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="79" value="Ссылка&lt;br&gt;на пакет документов" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" vertex="1" parent="4">
+        <mxCell id="79" value="Ссылка&lt;br&gt;на пакет документов" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="4" vertex="1">
           <mxGeometry x="1050" y="210" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="10" value="Создание заказа в системе, добавление товаров в заказ" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="4">
+        <mxCell id="10" value="Создание заказа в системе, добавление товаров в заказ" style="rounded=1;whiteSpace=wrap;html=1;" parent="4" vertex="1">
           <mxGeometry x="40" y="190" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="11" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="4" source="3" target="10">
+        <mxCell id="11" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="4" source="3" target="10" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="530" y="400" as="sourcePoint" />
             <mxPoint x="580" y="350" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="6" value="ДКР" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
+        <mxCell id="6" value="ДКР" style="swimlane;horizontal=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
           <mxGeometry y="360" width="1200" height="320" as="geometry">
             <mxRectangle y="360" width="40" height="60" as="alternateBounds" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="28" value="Формирование пакета документов для монтажа" style="whiteSpace=wrap;html=1;rounded=1;" vertex="1" parent="6">
+        <mxCell id="28" value="Формирование пакета документов для монтажа" style="whiteSpace=wrap;html=1;rounded=1;" parent="6" vertex="1">
           <mxGeometry x="320" y="240" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="7" value="Создание записи заказа" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="6">
+        <mxCell id="7" value="Создание записи заказа, привязка товаров к заказу по количество" style="rounded=1;whiteSpace=wrap;html=1;" parent="6" vertex="1">
           <mxGeometry x="40" y="50" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="9" value="Создание записей в таблице СКУ&lt;br&gt;(складской учет), связь с заказом" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="6">
+        <mxCell id="9" value="Создание записей в таблице СКУ&lt;br&gt;(складской учет)" style="rounded=1;whiteSpace=wrap;html=1;" parent="6" vertex="1">
           <mxGeometry x="40" y="150" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="13" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="6" source="7" target="9">
+        <mxCell id="13" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="6" source="7" target="9" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="370" y="140" as="sourcePoint" />
             <mxPoint x="420" y="90" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="25" value="Смена статуса &quot;Готов к монтажу&quot;" style="whiteSpace=wrap;html=1;rounded=1;" vertex="1" parent="6">
+        <mxCell id="25" value="Смена статуса &quot;Готов к монтажу&quot;" style="whiteSpace=wrap;html=1;rounded=1;" parent="6" vertex="1">
           <mxGeometry x="320" y="150" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="29" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="6" source="25" target="28">
+        <mxCell id="29" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="6" source="25" target="28" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="16" value="Пометка в СКУ поступившего товара (заполнение всех реквизитов)" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="6">
+        <mxCell id="16" value="Пометка в СКУ поступившего товара (заполнение всех реквизитов)" style="rounded=1;whiteSpace=wrap;html=1;" parent="6" vertex="1">
           <mxGeometry x="180" y="45" width="120" height="70" as="geometry" />
         </mxCell>
-        <mxCell id="39" value="да" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="6" source="35" target="25">
+        <mxCell id="39" value="да" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="6" source="35" target="25" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="35" value="товары в наличии" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="6">
+        <mxCell id="35" value="товары в наличии" style="rhombus;whiteSpace=wrap;html=1;" parent="6" vertex="1">
           <mxGeometry x="340" y="30" width="80" height="80" as="geometry" />
         </mxCell>
-        <mxCell id="49" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="6" source="46" target="48">
+        <mxCell id="49" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="6" source="46" target="48" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="46" value="Смена статуса заказа" style="whiteSpace=wrap;html=1;rounded=1;" vertex="1" parent="6">
+        <mxCell id="46" value="Смена статуса заказа" style="whiteSpace=wrap;html=1;rounded=1;" parent="6" vertex="1">
           <mxGeometry x="560" y="40" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="48" value="Формирование пакета документов для сдачи" style="whiteSpace=wrap;html=1;rounded=1;" vertex="1" parent="6">
+        <mxCell id="48" value="Формирование пакета документов для сдачи" style="whiteSpace=wrap;html=1;rounded=1;" parent="6" vertex="1">
           <mxGeometry x="560" y="180" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="59" value="Рекламация по отдельным МАФ ил всей площадке" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="6">
+        <mxCell id="59" value="Рекламация по отдельным МАФ ил всей площадке" style="rounded=1;whiteSpace=wrap;html=1;" parent="6" vertex="1">
           <mxGeometry x="790" y="45" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="67" value="Формирование пакета документов по реламации" style="whiteSpace=wrap;html=1;rounded=1;" vertex="1" parent="6">
+        <mxCell id="67" value="Формирование пакета документов по реламации" style="whiteSpace=wrap;html=1;rounded=1;" parent="6" vertex="1">
           <mxGeometry x="930" y="185" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="65" value="Рекламация закрыта" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="6">
+        <mxCell id="65" value="Рекламация закрыта" style="rounded=1;whiteSpace=wrap;html=1;" parent="6" vertex="1">
           <mxGeometry x="930" y="45" width="120" height="60" as="geometry" />
         </mxCell>
-        <mxCell id="68" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="6" source="65" target="67">
+        <mxCell id="68" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="6" source="65" target="67" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="15" target="16">
+        <mxCell id="21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="15" target="16" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="36" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="19" target="35">
+        <mxCell id="36" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="19" target="35" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="38" value="нет" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="35" target="37">
+        <mxCell id="38" value="нет" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="35" target="37" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="41" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="28" target="40">
+        <mxCell id="41" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="28" target="40" edge="1">
           <mxGeometry relative="1" as="geometry">
             <Array as="points">
               <mxPoint x="530" y="630" />
@@ -181,10 +181,10 @@
             </Array>
           </mxGeometry>
         </mxCell>
-        <mxCell id="47" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="44" target="46">
+        <mxCell id="47" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="44" target="46" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="51" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="48" target="50">
+        <mxCell id="51" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="48" target="50" edge="1">
           <mxGeometry relative="1" as="geometry">
             <Array as="points">
               <mxPoint x="760" y="570" />
@@ -192,16 +192,16 @@
             </Array>
           </mxGeometry>
         </mxCell>
-        <mxCell id="52" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" edge="1" parent="1">
+        <mxCell id="52" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;" parent="1" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="170" y="680" as="sourcePoint" />
             <mxPoint x="170" y="80" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="60" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="57" target="59">
+        <mxCell id="60" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="57" target="59" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
-        <mxCell id="80" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="67" target="79">
+        <mxCell id="80" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="67" target="79" edge="1">
           <mxGeometry relative="1" as="geometry">
             <Array as="points">
               <mxPoint x="1180" y="575" />
@@ -209,13 +209,13 @@
             </Array>
           </mxGeometry>
         </mxCell>
-        <mxCell id="12" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="10" target="7">
+        <mxCell id="12" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="10" target="7" edge="1">
           <mxGeometry width="50" height="50" relative="1" as="geometry">
             <mxPoint x="370" y="500" as="sourcePoint" />
             <mxPoint x="420" y="450" as="targetPoint" />
           </mxGeometry>
         </mxCell>
-        <mxCell id="66" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="64" target="65">
+        <mxCell id="66" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="64" target="65" edge="1">
           <mxGeometry relative="1" as="geometry" />
         </mxCell>
       </root>

+ 1 - 0
database/migrations/2025_03_30_101937_create_order_product_table.php

@@ -15,6 +15,7 @@ return new class extends Migration
             $table->id();
             $table->foreignId('order_id')->constrained()->cascadeOnDelete();
             $table->foreignId('product_id')->constrained()->cascadeOnDelete();
+            $table->unsignedMediumInteger('quantity')->default(1);
         });
     }
 

+ 4 - 0
resources/sass/app.scss

@@ -56,6 +56,10 @@
   background-color: #fff8ca;
 }
 
+.quantity {
+  padding: 3px;
+}
+
 .pagination .text-muted {
   padding-right: 1rem;
 }

+ 23 - 6
resources/views/orders/edit.blade.php

@@ -55,9 +55,18 @@
                     @if(isset($order) && $order->products)
                         @foreach($order->products as $p)
                             <div class="maf d-flex justify-content-between mb-1">
-                                <input type="hidden" class="visually-hidden" name="products[]" value="{{ $p->id }}">
-                                <div>{!! $p->common_name !!}</div>
-                                <i onclick="$(this).parent().remove(); $('.changes-message').removeClass('visually-hidden');" class="bi bi-trash text-danger cursor-pointer"></i>
+                                <div>
+                                    <input type="hidden" class="visually-hidden" name="products[]" value="{{ $p->id }}">
+                                    <div class="p-1">{!! $p->common_name !!}</div>
+                                </div>
+                                <div class="col-1 d-flex justify-content-end">
+                                    <div>
+                                        <input class="form-control text-end form-control-sm quantity" type="number" name="quantity[]" value="{{ $p->pivot->quantity }}">
+                                    </div>
+                                    <div class="p-1">
+                                        <i onclick="$(this).parent().remove(); $('.changes-message').removeClass('visually-hidden');" class="bi bi-trash text-danger cursor-pointer"></i>
+                                    </div>
+                                </div>
                             </div>
                         @endforeach
                     @endif
@@ -96,9 +105,17 @@
         selectMaf.on('change', function () {
             $('#selected_maf').append(
                 '<div class="maf  d-flex justify-content-between mb-1">' +
-                '<input type="hidden" name="products[]" value="'+ $(this).val() +'">' +
-                '<div>'+ $('#select_maf option:selected').text() +'</div> ' +
-                '<i onclick="$(this).parent().remove();" class="bi bi-trash text-danger cursor-pointer"></i>' +
+                    '<div>' +
+                        '<input type="hidden" name="products[]" value="'+ $(this).val() +'">' +
+                        '<div class="p-1">'+ $('#select_maf option:selected').text() +'</div> ' +
+                    '</div>' +
+                '<div class="col-1 d-flex justify-content-end">' +
+                    '<div>' +
+                        '<input class="form-control text-end form-control-sm quantity" type="number" name="quantity[]" value="1">' +
+                    '</div>' +
+                    '<div class="p-1">' +
+                        '<i onclick="$(this).parent().remove();" class="bi bi-trash text-danger cursor-pointer"></i>' +
+                    '</div>' +
                 '</div>'
             );
             $('#select_maf').children().remove();