]> _ Git - pmi.git/commitdiff
wip #2810 @12
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 6 Jun 2019 14:31:07 +0000 (16:31 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 6 Jun 2019 14:31:07 +0000 (16:31 +0200)
app/Http/Controllers/Admin/CategoryCrudController.php
app/Http/Controllers/Admin/ProductCrudController.php
app/Http/Controllers/Admin/ProductTypeCrudController.php
app/Http/Controllers/Admin/SpecificationCrudController.php
app/Http/Kernel.php
app/Models/Category.php
app/Models/Product.php
app/Models/Producttype.php
app/Models/Specification.php
resources/views/vendor/backpack/base/inc/sidebar_content.blade.php
routes/backpack/custom.php

index f75455ecfbf612a5b40728ad9f83aca3717c878a..526898bbc22a15e5acf00b7ffca9900388098b67 100644 (file)
@@ -7,8 +7,9 @@ use Cubist\Backpack\app\Magic\Controllers\CubistMagicNestedController;
 class CategoryCrudController extends CubistMagicNestedController
 {
     protected $_modelNamespace = 'App\Models\Category';
-    protected $_routeURL = 'category';
+    protected $_routeURL = 'catalog_category';
     protected $_singular = 'category';
     protected $_plural = 'categories';
     protected $_clonable = true;
+    protected $_bulk = true;
 }
index 49264163439e13b3c105f5edec0376adcdbb893a..32de144a5e419286d18329e6baf7731b6049ec9b 100644 (file)
@@ -11,4 +11,5 @@ class ProductCrudController extends CubistMagicController
     protected $_singular = 'product';
     protected $_plural = 'products';
     protected $_clonable = true;
+    protected $_bulk = true;
 }
index 5cde01cea7dfd5d11580f1ecbec491ddfa46f24a..67e2e60eb25320552213ef94b1cc4937d3729647 100644 (file)
@@ -11,4 +11,5 @@ class ProductTypeCrudController extends CubistMagicController
     protected $_singular = 'product type';
     protected $_plural = 'product types';
     protected $_clonable = true;
+    protected $_bulk = true;
 }
index 3711188fabfc5fc4113042640b47b090776da17f..263bb590a3f8349ec342555c42299343b7fbd1d3 100644 (file)
@@ -11,4 +11,5 @@ class SpecificationCrudController extends CubistMagicController
     protected $_singular = 'specification';
     protected $_plural = 'specifications';
     protected $_clonable = true;
+    protected $_bulk = true;
 }
index 8c362866ff33b9f047170d73f8dd6e33113fa32d..415c2d17b1d688df5f8426061453937c746d17d9 100644 (file)
@@ -17,7 +17,7 @@ class Kernel extends HttpKernel
         \App\Http\Middleware\CheckForMaintenanceMode::class,
         \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
         \App\Http\Middleware\TrimStrings::class,
-        //\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
         \App\Http\Middleware\TrustProxies::class,
         \Spatie\MissingPageRedirector\RedirectsMissingPages::class,
     ];
index 372fe12c27660a5da2a673f7479156e15c5a4cca..0622bf2700ac7b214babbd1dc42a9a1df130b5d9 100644 (file)
@@ -9,7 +9,8 @@ class Category extends CubistMagicNestedModel
     protected $table = 'catalog_categories';
 
     protected $_options = ['name' => 'category',
-        'plural' => 'categories'];
+        'plural' => 'categories',
+        'route'=>'catalog_category'];
 
     public function setFields()
     {
index 4661e4e442328b732a5e673182aa0174d579b838..80993f55016a357668519601483e6922caf1d572 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Models;
 
 use Cubist\Backpack\app\Magic\Models\CubistMagicModel;
+use Illuminate\Support\Str;
 
 class Product extends CubistMagicModel
 {
@@ -18,67 +19,108 @@ class Product extends CubistMagicModel
         $this->addField(['name' => 'name',
             'label' => 'Product name',
             'type' => 'Text',
-            'column' => true]);
+            'column' => true,
+            'tab' => 'General']);
 
         $this->addField(['name' => 'reference',
             'label' => 'SKU',
             'type' => 'Text',
             'column' => true,
             'unique' => true,
-            'translatable' => false]);
+            'translatable' => false,
+            'tab' => 'General']);
 
         $this->addField(['name' => 'product_type',
             'label' => 'Type de produit',
             'type' => 'SelectFromModel',
-            'model' => 'App\Models\ProductType']);
+            'model' => 'App\Models\ProductType',
+            'column' => true,
+            'tab' => 'General']);
+
+        $specifications = Specification::all();
+        foreach ($specifications as $spec) {
+            $params = ['tab' => 'Specifications',
+                'name' => 's_' . Str::snake($spec->name),
+                'label' => $spec->name,
+                'fake' => true,
+                'store_in' => 'specifications',
+            ];
+
+            if ($spec->type == 'numeric') {
+                $params['type'] = 'Number';
+            } else {
+                $params['type'] = 'SelectFromArray';
+                $options = [];
+                if (is_string($spec->options)) {
+                    $decoded = json_decode($spec->options);
+                }
+                foreach ($decoded as $option) {
+                    $options[] = $option->name;
+                }
+                $params['options'] = $options;
+            }
+            $this->addField($params);
+        }
+
 
         $this->addField(['name' => 'slug',
             'type' => 'Slug',
             'label' => 'Slug',
-            'column' => true]);
+            'column' => true,
+            'tab' => 'General']);
 
         $this->addField(['name' => 'online',
             'type' => 'Checkbox',
             'label' => 'Online',
-            'column' => true]);
+            'column' => true,
+            'tab' => 'General']);
 
         $this->addField(['name' => 'public',
             'type' => 'Checkbox',
             'label' => 'Public',
-            'column' => true]);
+            'column' => true,
+            'tab' => 'General']);
 
         $this->addField(['name' => 'supplier',
             'label' => 'Supplier',
             'type' => 'Text',
-            'translatable' => false]);
+            'translatable' => false,
+            'tab' => 'Supplier']);
 
         $this->addField(['name' => 'supplier_reference',
             'label' => 'Supplier reference',
             'type' => 'Text',
-            'translatable' => false]);
+            'translatable' => false,
+            'tab' => 'Supplier']);
 
         $this->addField(['name' => 'highlights',
             'label' => 'Product highlights',
-            'type' => 'Markdown']);
+            'type' => 'Markdown',
+            'tab' => 'Texts']);
 
         $this->addField(['name' => 'descriptions',
             'label' => 'Description',
-            'type' => 'Markdown']);
+            'type' => 'Markdown',
+            'tab' => 'Texts']);
 
         $this->addField(['name' => 'images',
             'label' => 'Product pictures',
-            'type' => 'Images']);
+            'type' => 'Images',
+            'tab' => 'Media']);
 
         $this->addField(['name' => 'dimensions',
             'label' => 'Dimensions',
-            'type' => 'Markdown']);
+            'type' => 'Markdown',
+            'tab' => 'Texts']);
 
         $this->addField(['name' => 'options',
             'label' => 'Options',
-            'type' => 'Markdown']);
+            'type' => 'Markdown',
+            'tab' => 'Texts']);
 
         $this->addField(['name' => 'accessories',
             'label' => 'Accessories',
-            'type' => 'Markdown']);
+            'type' => 'Markdown',
+            'tab' => 'Texts']);
     }
 }
index 499a3c586a4adc0438110e37b7598e9f3a22922a..830d24a7af7c8f4b9d87d139c577ebcaf25bc4ed 100644 (file)
@@ -19,10 +19,29 @@ class ProductType extends CubistMagicModel
             'type' => 'Text',
             'column' => true]);
 
+        $this->addField(['name' => 'type',
+                'label' => 'Product family',
+                'type' => 'SelectFromArray',
+                'options' => ['captor' => 'Captor', 'system' => 'System'],
+                'column' => true,
+            ]
+        );
+
+        $this->addField(['name' => 'featured_on_home',
+            'label' => 'Featured on homepage',
+            'type' => 'Checkbox',
+            'column' => true,
+            'default' => 1]);
+
         $this->addField(['name' => 'specifications',
             'label' => 'Specifications',
             'type' => 'SelectFromModelMultiple',
             'model' => "App\Models\Specification",
         ]);
     }
+
+    public function specifications()
+    {
+        return $this->relationship('specifications');
+    }
 }
index 39be6565dfff97d57a7a3b8ac09cf61d748e8c21..0ee9a22ab3feab3ac1188d2cd375746edbf6a963 100644 (file)
@@ -33,6 +33,13 @@ class Specification extends CubistMagicModel
             'entity_singular' => 'option', // used on the "Add X" button
             'columns' => [
                 'name' => 'Name',
-            ],]);
+            ],
+        ]);
     }
+
+    public function product_type()
+    {
+        return $this->belongsToMany('App\Models\ProductType', 'rel_btm_catalog_specifications_catalog_product_types');
+    }
+
 }
index 5fde75676cbf478649fd444a4e6b1fdf0a18787f..bfd2a9028ab6372b9e25a18da64980669fe7f965 100644 (file)
@@ -28,7 +28,7 @@
     <li><a href='{{ backpack_url('producttype') }}'><i class='fa fa-wpforms'></i> <span>Product types</span></a></li>
     <li><a href='{{ backpack_url('specification') }}'><i class='fa fa-align-left'></i> <span>Specifications</span></a>
     </li>
-    <li><a href='{{ backpack_url('category') }}'><i class='fa fa-folder-open'></i> <span>Categories</span></a></li>
+    <li><a href='{{ backpack_url('catalog_category') }}'><i class='fa fa-folder-open'></i> <span>Categories</span></a></li>
 @endcan
 
 @can('backpack_maintenance')
index b9d58b57fcb9721cab256717f41ce638faa78ceb..d12a933b773b3d515d3c5214d53f32249d836e9b 100644 (file)
@@ -4,7 +4,7 @@ Route::group([
     'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
     'namespace'  => 'App\Http\Controllers\Admin',
 ], function () { // custom admin routes
-    CRUD::resource('category', 'CategoryCrudController');
+    CRUD::resource('catalog_category', 'CategoryCrudController');
     CRUD::resource('product', 'ProductCrudController');
     CRUD::resource('producttype', 'ProductTypeCrudController');
     CRUD::resource('specification', 'SpecificationCrudController');