]> _ Git - pmi.git/commitdiff
wip #2810 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 31 May 2019 18:29:04 +0000 (20:29 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 31 May 2019 18:29:04 +0000 (20:29 +0200)
13 files changed:
app/Http/Controllers/Admin/CategoryCrudController.php
app/Http/Controllers/Admin/ProductCrudController.php
app/Http/Controllers/Admin/ProductTypeCrudController.php [new file with mode: 0644]
app/Http/Controllers/Admin/SpecificationCrudController.php [new file with mode: 0644]
app/Http/Controllers/Admin/SpecificationsCrudController.php [deleted file]
app/Http/Kernel.php
app/Models/Category.php
app/Models/Product.php
app/Models/Producttype.php [new file with mode: 0644]
app/Models/Specification.php
config/backpack/base.php
config/backpack/crud.php
routes/backpack/custom.php

index 1d0f17602c06409ddd699bdd124efaa59fc6301a..f75455ecfbf612a5b40728ad9f83aca3717c878a 100644 (file)
@@ -2,12 +2,13 @@
 
 namespace App\Http\Controllers\Admin;
 
-use Cubist\Backpack\app\Magic\Controllers\CubistNestedMagicController;
+use Cubist\Backpack\app\Magic\Controllers\CubistMagicNestedController;
 
-class CategoryCrudController extends CubistNestedMagicController
+class CategoryCrudController extends CubistMagicNestedController
 {
     protected $_modelNamespace = 'App\Models\Category';
     protected $_routeURL = 'category';
     protected $_singular = 'category';
     protected $_plural = 'categories';
+    protected $_clonable = true;
 }
index dec6f4bd70626f8e4233b4daba7a828e068a4744..49264163439e13b3c105f5edec0376adcdbb893a 100644 (file)
@@ -10,4 +10,5 @@ class ProductCrudController extends CubistMagicController
     protected $_routeURL = 'product';
     protected $_singular = 'product';
     protected $_plural = 'products';
+    protected $_clonable = true;
 }
diff --git a/app/Http/Controllers/Admin/ProductTypeCrudController.php b/app/Http/Controllers/Admin/ProductTypeCrudController.php
new file mode 100644 (file)
index 0000000..8c6e381
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use Cubist\Backpack\app\Magic\Controllers\CubistMagicController;
+
+class ProductTypeCrudController extends CubistMagicController
+{
+    protected $_modelNamespace = 'App\Models\ProductType';
+    protected $_routeURL = 'product type';
+    protected $_singular = 'product type';
+    protected $_plural = 'product types';
+    protected $_clonable = true;
+}
diff --git a/app/Http/Controllers/Admin/SpecificationCrudController.php b/app/Http/Controllers/Admin/SpecificationCrudController.php
new file mode 100644 (file)
index 0000000..3711188
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use Cubist\Backpack\app\Magic\Controllers\CubistMagicController;
+
+class SpecificationCrudController extends CubistMagicController
+{
+    protected $_modelNamespace = 'App\Models\Specification';
+    protected $_routeURL = 'specification';
+    protected $_singular = 'specification';
+    protected $_plural = 'specifications';
+    protected $_clonable = true;
+}
diff --git a/app/Http/Controllers/Admin/SpecificationsCrudController.php b/app/Http/Controllers/Admin/SpecificationsCrudController.php
deleted file mode 100644 (file)
index afbcea9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Admin;
-
-use Cubist\Backpack\app\Magic\Controllers\CubistMagicController;
-
-class SpecificationsCrudController extends CubistMagicController
-{
-    protected $_modelNamespace = 'App\Models\Specification';
-    protected $_routeURL = 'specifications';
-    protected $_singular = 'specifications';
-    protected $_plural = 'products';
-}
index 415c2d17b1d688df5f8426061453937c746d17d9..8c362866ff33b9f047170d73f8dd6e33113fa32d 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 e8019bb7e9197c7b3345acdecf0665b91a9ca891..12b31f5e997bac41d0cea096c73a6ceb7945a4ac 100644 (file)
@@ -2,17 +2,15 @@
 
 namespace App\Models;
 
-use Cubist\Backpack\app\Magic\Models\CubistMagicModel;
+use Cubist\Backpack\app\Magic\Models\CubistMagicNestedModel;
 
-class Category extends CubistMagicModel
+class Category extends CubistMagicNestedModel
 {
     protected $table = 'categories';
 
     protected $_options = ['name' => 'category',
         'plural' => 'categories'];
 
-    protected $nested = true;
-
     public function setFields()
     {
         parent::setFields();
@@ -25,7 +23,8 @@ class Category extends CubistMagicModel
         $this->addField(['name' => 'slug',
             'type' => 'Slug',
             'label' => 'Slug',
-            'column' => true]);
+            'column' => true]
+        );
 
 
     }
index 0d5516ce3eb67bdb128ee2bb4c49b49fbd09ee71..938ccb0d229f1450ed5bfcb625165696db4176e4 100644 (file)
@@ -11,8 +11,6 @@ class Product extends CubistMagicModel
     protected $_options = ['name' => 'product',
         'plural' => 'products'];
 
-    protected $nested = false;
-
     public function setFields()
     {
         parent::setFields();
@@ -26,7 +24,8 @@ class Product extends CubistMagicModel
             'label' => 'SKU',
             'type' => 'Text',
             'column' => true,
-            'unique' => true]);
+            'unique' => true,
+            'translatable' => false]);
 
         $this->addField(['name' => 'slug',
             'type' => 'Slug',
@@ -45,11 +44,13 @@ class Product extends CubistMagicModel
 
         $this->addField(['name' => 'supplier',
             'label' => 'Supplier',
-            'type' => 'Text']);
+            'type' => 'Text',
+            'translatable' => false]);
 
         $this->addField(['name' => 'supplier_reference',
             'label' => 'Supplier reference',
-            'type' => 'Text']);
+            'type' => 'Text',
+            'translatable' => false]);
 
         $this->addField(['name' => 'highlights',
             'label' => 'Product highlights',
@@ -74,6 +75,5 @@ class Product extends CubistMagicModel
         $this->addField(['name' => 'accessories',
             'label' => 'Accessories',
             'type' => 'Markdown']);
-
     }
 }
diff --git a/app/Models/Producttype.php b/app/Models/Producttype.php
new file mode 100644 (file)
index 0000000..9b2ed57
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+namespace App\Models;
+
+use Cubist\Backpack\app\Magic\Models\CubistMagicModel;
+
+class ProductType extends CubistMagicModel
+{
+    protected $table = 'product_types';
+
+    protected $_options = ['name' => 'product type',
+        'plural' => 'product types'];
+
+    public function setFields()
+    {
+        $this->addField(['name' => 'name',
+            'label' => 'Type name',
+            'type' => 'Text',
+            'column' => true]);
+
+        $this->addField(['name' => 'specifications',
+            'label' => 'Specifications',
+            'type' => 'SelectFromModelMultiple',
+            'model' => "App\Models\Specification",
+        ]);
+    }
+}
index a7c512afa81c068a183011b1cc0d56a1a94f0219..7da59de12aee45369ea23177edb997228b341b9e 100644 (file)
@@ -9,8 +9,8 @@ class Specification extends CubistMagicModel
 {
     protected $table = 'specifications';
 
-    protected $_options = ['name' => 'specifications',
-        'plural' => 'products'];
+    protected $_options = ['name' => 'specification',
+        'plural' => 'specifications'];
 
     public function setFields()
     {
index c2f3eb1948621b711ed2dd8869829b887f9a81f5..2a6c5436103b3001a121d07db36aa86462bccb7b 100644 (file)
@@ -94,7 +94,7 @@ return [
     // Can be a single class or an array of clases
     'middleware_class' => [
         App\Http\Middleware\CheckIfAdmin::class,
-        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+        //\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
         Backpack\Base\app\Http\Middleware\UseBackpackAuthGuardInsteadOfDefaultAuthGuard::class,
     ],
 
index dc47c25edd6c64be53835cc208f4e484fd0cd5cf..2634c87bced6a9d592ed73239055b399c3ec1014 100644 (file)
@@ -33,11 +33,11 @@ return [
 
     // Here you may override the css-classes for the content section of the edit view globally
     // To override per view use $this->crud->setEditContentClass('class-string')
-    'edit_content_class'   => 'col-md-8 col-md-offset-2',
+    'edit_content_class' => 'col-md-8 col-md-offset-2',
 
     // Here you may override the css-classes for the content section of the revisions timeline view globally
     // To override per view use $this->crud->setRevisionsTimelineContentClass('class-string')
-    'revisions_timeline_content_class'   => 'col-md-10 col-md-offset-1',
+    'revisions_timeline_content_class' => 'col-md-10 col-md-offset-1',
 
     /*
     |------------
@@ -73,7 +73,7 @@ return [
 
     // Here you may override the css-classes for the content section of the show view globally
     // To override per view use $this->crud->setShowContentClass('class-string')
-    'show_content_class'   => 'col-md-8 col-md-offset-2',
+    'show_content_class' => 'col-md-8 col-md-offset-2',
 
     /*
     |------------
@@ -89,7 +89,7 @@ return [
 
     // Here you may override the css-classes for the content section of the reorder view globally
     // To override per view use $this->crud->setReorderContentClass('class-string')
-    'reorder_content_class'   => 'col-md-8 col-md-offset-2',
+    'reorder_content_class' => 'col-md-8 col-md-offset-2',
 
     /*
     |------------
@@ -282,7 +282,7 @@ return [
         // "de_LI" => "German (Liechtenstein)",
         // "de_LU" => "German (Luxembourg)",
         // "de_CH" => "German (Switzerland)",
-        // "de" => "German",
+        "de" => "German",
         // "el_CY" => "Greek (Cyprus)",
         // "el_GR" => "Greek (Greece)",
         // "el" => "Greek",
@@ -313,7 +313,7 @@ return [
         // "ga" => "Irish",
         // "it_IT" => "Italian (Italy)",
         // "it_CH" => "Italian (Switzerland)",
-        'it' => 'Italian',
+        //'it' => 'Italian',
         // "ja_JP" => "Japanese (Japan)",
         // "ja" => "Japanese",
         // "kea_CV" => "Kabuverdianu (Cape Verde)",
@@ -418,7 +418,7 @@ return [
         // "pa" => "Punjabi",
         // "ro_MD" => "Romanian (Moldova)",
         // "ro_RO" => "Romanian (Romania)",
-        'ro' => 'Romanian',
+        //'ro' => 'Romanian',
         // "rm_CH" => "Romansh (Switzerland)",
         // "rm" => "Romansh",
         // "rof_TZ" => "Rombo (Tanzania)",
index 283c468485d700d2bd1035a6878579ab17b51575..a3449837e022104f2984f41f4fac14117f0d7fd6 100644 (file)
@@ -6,5 +6,6 @@ Route::group([
 ], function () { // custom admin routes
     CRUD::resource('category', 'CategoryCrudController');
 CRUD::resource('product', 'ProductCrudController');
-CRUD::resource('specifications', 'SpecificationsCrudController');
+CRUD::resource('product type', 'ProductTypeCrudController');
+CRUD::resource('specification', 'SpecificationCrudController');
 }); // this should be the absolute last line of this file