From 6e97b368e72e911f6dbdfc17832a62bd877dbb65 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 7 Jun 2019 17:37:12 +0200 Subject: [PATCH] #2810 --- .env.production | 1 + app/Models/Category.php | 3 ++- app/Models/Product.php | 35 +++++++++++++++++++++++++---------- app/Models/Producttype.php | 20 ++++++++++++++++---- app/Models/Specification.php | 31 ++++++++++++++++++++++++++----- config/app.php | 2 +- config/backpack/crud.php | 7 +++++-- 7 files changed, 76 insertions(+), 23 deletions(-) diff --git a/.env.production b/.env.production index bd70f01..5dcfe61 100644 --- a/.env.production +++ b/.env.production @@ -39,3 +39,4 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" GOOGLE_ANALYTICS_ID=UA-4339912-10 +BACKPACK_LICENSE=YwdOWjeEczPAwy06GzkBJggW diff --git a/app/Models/Category.php b/app/Models/Category.php index 57edddd..99b94ae 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -9,7 +9,8 @@ class Category extends CubistMagicNestedModel protected $table = 'catalog_categories'; protected $_options = ['name' => 'category', - 'plural' => 'categories', + 'singular' => 'catégorie', + 'plural' => 'catégories', 'route' => 'catalog_category']; public function setFields() diff --git a/app/Models/Product.php b/app/Models/Product.php index dbb4a3c..e5384a9 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -11,20 +11,21 @@ class Product extends CubistMagicModel protected $table = 'catalog_products'; protected $_options = ['name' => 'product', - 'plural' => 'products']; + 'singular'=>'produit', + 'plural' => 'produits']; public function setFields() { parent::setFields(); $this->addField(['name' => 'name', - 'label' => 'Product name', + 'label' => 'Nom du produit', 'type' => 'Text', 'column' => true, 'tab' => 'General']); $this->addField(['name' => 'reference', - 'label' => 'SKU', + 'label' => 'SKU (référence)', 'type' => 'Text', 'column' => true, 'unique' => true, @@ -50,6 +51,9 @@ class Product extends CubistMagicModel } } } + if (!count($in)) { + continue; + } $params = ['tab' => 'Specifications', 'name' => 's_' . Str::snake($spec->name), 'label' => $spec->name, @@ -58,8 +62,19 @@ class Product extends CubistMagicModel 'when' => ['product_type' => $in], ]; + if ($spec->prefix) { + $params['prefix'] = $spec->prefix; + } + if ($spec->unit) { + $params['suffix'] = $spec->unit; + } + if ($spec->type == 'numeric') { $params['type'] = 'Number'; + } else if ($spec->type == 'range') { + $params['type'] = 'Range'; + } else if ($spec->type == 'text') { + $params['type'] = 'Text'; } else { $params['type'] = 'SelectFromArray'; $options = []; @@ -76,31 +91,31 @@ class Product extends CubistMagicModel $this->addField(['name' => 'slug', - 'type' => 'Slug', + 'type' => 'Slug (URL)', 'label' => 'Slug', 'column' => true, 'tab' => 'General']); $this->addField(['name' => 'online', 'type' => 'Checkbox', - 'label' => 'Online', + 'label' => 'En ligne', 'column' => true, 'tab' => 'General']); $this->addField(['name' => 'public', 'type' => 'Checkbox', - 'label' => 'Public', + 'label' => 'Publique', 'column' => true, 'tab' => 'General']); $this->addField(['name' => 'supplier', - 'label' => 'Supplier', + 'label' => 'Fournisseur', 'type' => 'Text', 'translatable' => false, 'tab' => 'Supplier']); $this->addField(['name' => 'supplier_reference', - 'label' => 'Supplier reference', + 'label' => 'Référence fournisseur', 'type' => 'Text', 'translatable' => false, 'tab' => 'Supplier']); @@ -116,7 +131,7 @@ class Product extends CubistMagicModel 'tab' => 'Texts']); $this->addField(['name' => 'images', - 'label' => 'Product pictures', + 'label' => 'Images du produit', 'type' => 'Images', 'tab' => 'Media']); @@ -131,7 +146,7 @@ class Product extends CubistMagicModel 'tab' => 'Texts']); $this->addField(['name' => 'accessories', - 'label' => 'Accessories', + 'label' => 'Accessoires', 'type' => 'Markdown', 'tab' => 'Texts']); diff --git a/app/Models/Producttype.php b/app/Models/Producttype.php index 830d24a..75adaf7 100644 --- a/app/Models/Producttype.php +++ b/app/Models/Producttype.php @@ -10,12 +10,14 @@ class ProductType extends CubistMagicModel protected $_options = ['name' => 'product type', 'route' => 'producttype', - 'plural' => 'product types']; + 'singular' => 'type de produit', + 'plural' => 'types de produit' + ]; public function setFields() { $this->addField(['name' => 'name', - 'label' => 'Type name', + 'label' => 'Nom du type de produit', 'type' => 'Text', 'column' => true]); @@ -28,13 +30,18 @@ class ProductType extends CubistMagicModel ); $this->addField(['name' => 'featured_on_home', - 'label' => 'Featured on homepage', + 'label' => 'Mis en avant sur la page d\'accueil', 'type' => 'Checkbox', 'column' => true, 'default' => 1]); + $this->addField(['name' => 'filters', + 'label' => 'Spécifications utilisées comme filtre', + 'type' => 'SelectFromModelMultiple', + 'model' => 'App\Models\Specification']); + $this->addField(['name' => 'specifications', - 'label' => 'Specifications', + 'label' => 'Autre spécifications', 'type' => 'SelectFromModelMultiple', 'model' => "App\Models\Specification", ]); @@ -44,4 +51,9 @@ class ProductType extends CubistMagicModel { return $this->relationship('specifications'); } + + public function filters() + { + return $this->relationship('filters'); + } } diff --git a/app/Models/Specification.php b/app/Models/Specification.php index 0ee9a22..fac4b39 100644 --- a/app/Models/Specification.php +++ b/app/Models/Specification.php @@ -10,14 +10,15 @@ class Specification extends CubistMagicModel protected $table = 'catalog_specifications'; protected $_options = ['name' => 'specification', - 'plural' => 'specifications']; + 'singular' => 'spécification', + 'plural' => 'spécifications']; public function setFields() { parent::setFields(); $this->addField(['name' => 'name', - 'label' => 'Specification name', + 'label' => 'Nom de la spécification', 'type' => 'Text', 'column' => true]); @@ -25,7 +26,7 @@ class Specification extends CubistMagicModel 'label' => 'Type', 'type' => 'SelectFromArray', 'column' => true, - 'options' => ['numeric' => 'Numeric value', 'list' => 'Value in a list']]); + 'options' => ['numeric' => 'Numeric value', 'range' => 'Numeric range', 'list' => 'Value in a list', 'text' => 'Text value']]); $this->addField(['name' => 'options', 'label' => 'Options', @@ -34,12 +35,32 @@ class Specification extends CubistMagicModel 'columns' => [ 'name' => 'Name', ], + 'when' => ['type' => 'list'], ]); + + $this->addField(['name' => 'prefix', + 'label' => 'Préfixe', + 'type' => 'SelectFromArray', + 'options' => ['' => 'no prefix', '>' => '>', '<' => '<', '±' => '±', '≥' => '≥', '≤' => '≤'], + 'when' => ['type' => 'numeric'] + ]); + + $this->addField(['name' => 'unit', + 'label' => 'Unité', + 'type' => 'Text', + 'when' => ['type' => ['numeric', 'interval']], + 'translatable' => false, + ]); + } + + public function product_type_filters() + { + return $this->belongsToMany('App\Models\ProductType', 'catalog_product_types_filters_rel_btm'); } - public function product_type() + public function product_type_specifications() { - return $this->belongsToMany('App\Models\ProductType', 'rel_btm_catalog_specifications_catalog_product_types'); + return $this->belongsToMany('App\Models\ProductType', 'catalog_product_types_specifications_rel_btm'); } } diff --git a/config/app.php b/config/app.php index c800454..696ac99 100644 --- a/config/app.php +++ b/config/app.php @@ -80,7 +80,7 @@ return [ | */ - 'locale' => 'en', + 'locale' => 'fr', /* |-------------------------------------------------------------------------- diff --git a/config/backpack/crud.php b/config/backpack/crud.php index 2634c87..470bc49 100644 --- a/config/backpack/crud.php +++ b/config/backpack/crud.php @@ -107,6 +107,9 @@ return [ 'translatable_field_icon_position' => 'right', // left or right 'locales' => [ + 'fr' => 'French', + 'en' => 'English', + "de" => "German", // "af_NA" => "Afrikaans (Namibia)", // "af_ZA" => "Afrikaans (South Africa)", // "af" => "Afrikaans", @@ -223,7 +226,7 @@ return [ // "en_GB" => "English (United Kingdom)", // "en_US" => "English (United States)", // "en_ZW" => "English (Zimbabwe)", - 'en' => 'English', + // "eo" => "Esperanto", // "et_EE" => "Estonian (Estonia)", // "et" => "Estonian", @@ -282,7 +285,7 @@ return [ // "de_LI" => "German (Liechtenstein)", // "de_LU" => "German (Luxembourg)", // "de_CH" => "German (Switzerland)", - "de" => "German", + // "el_CY" => "Greek (Cyprus)", // "el_GR" => "Greek (Greece)", // "el" => "Greek", -- 2.39.5