From 3acb6854abfe6fff9ebfa354a5fa81adec2a98d3 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 31 May 2019 20:29:04 +0200 Subject: [PATCH] wip #2810 @3 --- .../Admin/CategoryCrudController.php | 5 ++-- .../Admin/ProductCrudController.php | 1 + .../Admin/ProductTypeCrudController.php | 14 ++++++++++ .../Admin/SpecificationCrudController.php | 14 ++++++++++ .../Admin/SpecificationsCrudController.php | 13 ---------- app/Http/Kernel.php | 2 +- app/Models/Category.php | 9 +++---- app/Models/Product.php | 12 ++++----- app/Models/Producttype.php | 26 +++++++++++++++++++ app/Models/Specification.php | 4 +-- config/backpack/base.php | 2 +- config/backpack/crud.php | 14 +++++----- routes/backpack/custom.php | 3 ++- 13 files changed, 81 insertions(+), 38 deletions(-) create mode 100644 app/Http/Controllers/Admin/ProductTypeCrudController.php create mode 100644 app/Http/Controllers/Admin/SpecificationCrudController.php delete mode 100644 app/Http/Controllers/Admin/SpecificationsCrudController.php create mode 100644 app/Models/Producttype.php diff --git a/app/Http/Controllers/Admin/CategoryCrudController.php b/app/Http/Controllers/Admin/CategoryCrudController.php index 1d0f176..f75455e 100644 --- a/app/Http/Controllers/Admin/CategoryCrudController.php +++ b/app/Http/Controllers/Admin/CategoryCrudController.php @@ -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; } diff --git a/app/Http/Controllers/Admin/ProductCrudController.php b/app/Http/Controllers/Admin/ProductCrudController.php index dec6f4b..4926416 100644 --- a/app/Http/Controllers/Admin/ProductCrudController.php +++ b/app/Http/Controllers/Admin/ProductCrudController.php @@ -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 index 0000000..8c6e381 --- /dev/null +++ b/app/Http/Controllers/Admin/ProductTypeCrudController.php @@ -0,0 +1,14 @@ + '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] + ); } diff --git a/app/Models/Product.php b/app/Models/Product.php index 0d5516c..938ccb0 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -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 index 0000000..9b2ed57 --- /dev/null +++ b/app/Models/Producttype.php @@ -0,0 +1,26 @@ + '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", + ]); + } +} diff --git a/app/Models/Specification.php b/app/Models/Specification.php index a7c512a..7da59de 100644 --- a/app/Models/Specification.php +++ b/app/Models/Specification.php @@ -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() { diff --git a/config/backpack/base.php b/config/backpack/base.php index c2f3eb1..2a6c543 100644 --- a/config/backpack/base.php +++ b/config/backpack/base.php @@ -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, ], diff --git a/config/backpack/crud.php b/config/backpack/crud.php index dc47c25..2634c87 100644 --- a/config/backpack/crud.php +++ b/config/backpack/crud.php @@ -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)", diff --git a/routes/backpack/custom.php b/routes/backpack/custom.php index 283c468..a344983 100644 --- a/routes/backpack/custom.php +++ b/routes/backpack/custom.php @@ -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 -- 2.39.5