Sfoglia il codice sorgente

added certificate filter

Alexander Musikhin 7 mesi fa
parent
commit
79769f4216
2 ha cambiato i file con 14 aggiunte e 2 eliminazioni
  1. 2 2
      app/Http/Controllers/ProductController.php
  2. 12 0
      app/Models/File.php

+ 2 - 2
app/Http/Controllers/ProductController.php

@@ -37,7 +37,7 @@ class ProductController extends Controller
             'total_price_txt'           => 'Итоговая цена',
             'note'                      => 'Примечания',
             'created_at'                => 'Дата создания',
-            'certificate-original_name' => 'Сертификат',
+            'certificate_id'            => 'Сертификат',
         ],
         'searchFields' =>  [
             'nomenclature_number',
@@ -52,7 +52,7 @@ class ProductController extends Controller
     {
         $model = new Product;
         // fill filters
-        $this->createFilters($model, 'type_tz', 'type');
+        $this->createFilters($model, 'type_tz', 'type', 'certificate_id');
         $this->createRangeFilters($model, 'nomenclature_number', 'product_price', 'installation_price', 'total_price');
         $this->createDateFilters($model, 'created_at');
 

+ 12 - 0
app/Models/File.php

@@ -2,6 +2,7 @@
 
 namespace App\Models;
 
+use Illuminate\Database\Eloquent\Casts\Attribute;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
@@ -15,9 +16,20 @@ class File extends Model
         'link',
     ];
 
+    protected $appends = [
+        'name',
+    ];
+
     public function user(): BelongsTo
     {
         return $this->belongsTo(User::class);
     }
 
+    public function name(): Attribute
+    {
+        return Attribute::make(
+            get: fn () => $this->original_name ?? '',
+        );
+    }
+
 }