Переглянути джерело

Merge remote-tracking branch 'origin/master'

Alexander Musikhin 7 місяців тому
батько
коміт
8b09914d64

+ 1 - 1
app/Http/Controllers/OrderController.php

@@ -37,7 +37,7 @@ class OrderController extends Controller
             'tg_group_name'             => 'Имя группы в ТГ',
             'tg_group_link'             => 'Ссылка на группу в ТГ',
             'products-common_name'      => 'МАФы',
-            'ready_to_mount'            => 'Готов к монтажу',
+            'ready_to_mount'            => 'Все МАФы на складе',
         ],
         'searchFields' => [
             'comment',

+ 7 - 3
app/Http/Controllers/ProductSKUController.php

@@ -8,17 +8,20 @@ use App\Models\ProductSKU;
 use Illuminate\Http\Request;
 use Illuminate\Support\Str;
 
-// Склад - Заказы МАФ
+// Склад - МАФ
 class ProductSKUController extends Controller
 {
     protected array $data = [
         'active'    => 'product_sku',
-        'title'     => 'Заказы МАФ',
+        'title'     => 'МАФ',
         'id'        => 'product_sku',
         'header'    => [
             'id'                                => 'ID',
 
-            'order-id'                          => 'ID площадки',
+            'order-district_id'                 => 'Округ',
+            'order-area_id'                     => 'Район',
+            'order-object_address'              => 'Адрес площадки',
+            'maf_order-order_number'            => 'Номер заказа МАФ',
 
             'status'                            => 'Статус',
             'rfid'                              => 'RFID',
@@ -42,6 +45,7 @@ class ProductSKUController extends Controller
             'rfid',
             'factory_number',
             'certificate_number',
+            'order-object_address',
             'product-nomenclature_number',
             'product-article',
         ],

+ 15 - 0
app/Models/Order.php

@@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
 use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasManyThrough;
 use Illuminate\Database\Eloquent\SoftDeletes;
 use Illuminate\Support\Facades\DB;
 
@@ -40,11 +41,18 @@ class Order extends Model
         'ready_to_mount',
     ];
 
+    public $appends = ['common_name'];
+
     public function products_sku(): HasMany
     {
         return $this->hasMany(ProductSKU::class, 'order_id', 'id');
     }
 
+    public function products(): HasManyThrough
+    {
+        return $this->hasManyThrough(Product::class, ProductSKU::class, 'order_id', 'id');
+    }
+
     public function maf_orders(): BelongsTo
     {
         return $this->belongsTo(MafOrder::class, 'maf_order_id');
@@ -113,5 +121,12 @@ class Order extends Model
 
        $this->update(['ready_to_mount' => ($result) ? 'Да' : 'Нет']);
     }
+
+    public function commonName(): Attribute
+    {
+        return Attribute::make(
+            get: fn($value) => (string) $this->district->shortname . ', ' . $this->area->name . ', ' . $this->object_address,
+        );
+    }
 }
 

+ 1 - 0
resources/views/layouts/menu.blade.php

@@ -1,4 +1,5 @@
 <li class="nav-item"><a class="nav-link" href="{{ route('order.index') }}">Площадки</a></li>
+<li class="nav-item"><a class="nav-link" href="{{ route('product_sku.index') }}">МАФ</a></li>
 <li class="nav-item"><a class="nav-link" href="{{ route('maf_order.index') }}">Заказы МАФ</a></li>
 
 <li class="nav-item"><a class="nav-link" href="{{ route('catalog.index') }}">Каталог</a></li>

+ 8 - 2
resources/views/partials/table.blade.php

@@ -56,13 +56,19 @@
 //                                var_dump($string->$rel);die();
                             @endphp
                             @if(isset($string->$rel->$field))
-                                {!! $string->$rel->$field !!}
+                                @if(str_ends_with($field, '_id'))
+                                @php
+                                    $relation = \Illuminate\Support\Str::camel(str_replace('_id', '', $field));
+                                @endphp
+                                    {!! $string->$rel->$relation?->name; !!}
+                                @else
+                                    {!! $string->$rel->$field !!}
+                                @endif
                             @else
                                 <ul class="small mb-0">
                                     @foreach($string->$rel ?? [] as $item)
                                         <li>
                                             {!! $item->$field !!}
-                                            / {{ $item?->pivot?->quantity }}
                                         </li>
                                     @endforeach
                                 </ul>

+ 1 - 1
resources/views/products_sku/index.blade.php

@@ -28,7 +28,7 @@
         </div>
     </div>
 
-    <!-- Модальное окно добавления-->
+    <!-- Модальное окно редактирования -->
     <div class="modal fade" id="addModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
         <div class="modal-dialog modal-fullscreen-sm-down modal-lg">
             <div class="modal-content">

+ 1 - 1
routes/web.php

@@ -60,7 +60,7 @@ Route::middleware('auth:web')->group(function () {
     Route::get('order/{order}/get-maf', [OrderController::class, 'getMafToOrder'])->name('order.get-maf');
     Route::get('order/destroy', [OrderController::class, 'destroy'])->name('order.destroy');
 
-    // Склад
+    // Склад (МАФ)
     Route::get('product_sku', [ProductSKUController::class, 'index'])->name('product_sku.index');
     Route::get('product_sku/{product_sku}', [ProductSKUController::class, 'show'])->name('product_sku.show');
     Route::post('product_sku/store', [ProductSKUController::class, 'store'])->name('product_sku.store');