From 66f37a78444b0369abefa0f912307e8a72bfd2f9 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 31 May 2019 11:31:14 +0200 Subject: [PATCH] wip #2810 @14 --- app/Models/Category.php | 2 + app/Models/Product.php | 79 ++++++++++++++++++++++++++++++++++++ app/Models/Specification.php | 38 +++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 app/Models/Product.php create mode 100644 app/Models/Specification.php diff --git a/app/Models/Category.php b/app/Models/Category.php index 9e0b378..1de50b3 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -11,6 +11,8 @@ class Category extends CubistMagicModelAbstract protected $_options = ['name' => 'category', 'plural' => 'categories']; + protected $nested = true; + public function setFields() { parent::setFields(); diff --git a/app/Models/Product.php b/app/Models/Product.php new file mode 100644 index 0000000..0d5516c --- /dev/null +++ b/app/Models/Product.php @@ -0,0 +1,79 @@ + 'product', + 'plural' => 'products']; + + protected $nested = false; + + public function setFields() + { + parent::setFields(); + + $this->addField(['name' => 'name', + 'label' => 'Product name', + 'type' => 'Text', + 'column' => true]); + + $this->addField(['name' => 'reference', + 'label' => 'SKU', + 'type' => 'Text', + 'column' => true, + 'unique' => true]); + + $this->addField(['name' => 'slug', + 'type' => 'Slug', + 'label' => 'Slug', + 'column' => true]); + + $this->addField(['name' => 'online', + 'type' => 'Checkbox', + 'label' => 'Online', + 'column' => true]); + + $this->addField(['name' => 'public', + 'type' => 'Checkbox', + 'label' => 'Public', + 'column' => true]); + + $this->addField(['name' => 'supplier', + 'label' => 'Supplier', + 'type' => 'Text']); + + $this->addField(['name' => 'supplier_reference', + 'label' => 'Supplier reference', + 'type' => 'Text']); + + $this->addField(['name' => 'highlights', + 'label' => 'Product highlights', + 'type' => 'Markdown']); + + $this->addField(['name' => 'descriptions', + 'label' => 'Description', + 'type' => 'Markdown']); + + $this->addField(['name' => 'images', + 'label' => 'Product pictures', + 'type' => 'Images']); + + $this->addField(['name' => 'dimensions', + 'label' => 'Dimensions', + 'type' => 'Markdown']); + + $this->addField(['name' => 'options', + 'label' => 'Options', + 'type' => 'Markdown']); + + $this->addField(['name' => 'accessories', + 'label' => 'Accessories', + 'type' => 'Markdown']); + + } +} diff --git a/app/Models/Specification.php b/app/Models/Specification.php new file mode 100644 index 0000000..a7c512a --- /dev/null +++ b/app/Models/Specification.php @@ -0,0 +1,38 @@ + 'specifications', + 'plural' => 'products']; + + public function setFields() + { + parent::setFields(); + + $this->addField(['name' => 'name', + 'label' => 'Specification name', + 'type' => 'Text', + 'column' => true]); + + $this->addField(['name' => 'type', + 'label' => 'Type', + 'type' => 'SelectFromArray', + 'column' => true, + 'options' => ['numeric' => 'Numeric value', 'list' => 'Value in a list']]); + + $this->addField(['name' => 'options', + 'label' => 'Options', + 'type' => 'Table', + 'entity_singular' => 'option', // used on the "Add X" button + 'columns' => [ + 'name' => 'Name', + ],]); + } +} -- 2.39.5