]> _ Git - pmi.git/commitdiff
wip #2941
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 20 Aug 2019 16:29:37 +0000 (18:29 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 20 Aug 2019 16:29:37 +0000 (18:29 +0200)
.env.production
.env.staging
app/Http/Controllers/NewsController.php
app/Http/Controllers/ProductController.php
app/Models/Product.php
app/Models/Producttype.php
app/Templates/Aboutus.php
app/Templates/Base.php
config/cubist.php
config/elasticsearch.php [new file with mode: 0644]

index 385c4251db835cfe807749ebcf9f0f92f7d202b3..b78b5befb8c93e1930dd410ee813506fbc3e4802 100644 (file)
@@ -43,6 +43,15 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
 GOOGLE_ANALYTICS_ID=UA-4339912-10
 BACKPACK_LICENSE=YwdOWjeEczPAwy06GzkBJggW
 
+CUBIST_INTERNAL_SEARCH=true
+
+ELASTICSEARCH_HOST=127.0.0.1
+ELASTICSEARCH_PORT=9200
+ELASTICSEARCH_SCHEME=http
+ELASTICSEARCH_USER=
+ELASTICSEARCH_PASS=
+ELASTICSEARCH_INDEX_NAME=pmi
+
 FEATURE_QUOTE=false
 FEATURE_NEWS=false
 FEATURE_SEARCH=false
index c581028f24a6b36040f1fec5d3d0ca013f7b9022..cc7b4c071b78942c8a6d03ed6cadf37479dfc578 100644 (file)
@@ -42,6 +42,15 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
 GOOGLE_ANALYTICS_ID=UA-4339912-10
 BACKPACK_LICENSE=YwdOWjeEczPAwy06GzkBJggW
 
+CUBIST_INTERNAL_SEARCH=true
+
+ELASTICSEARCH_HOST=127.0.0.1
+ELASTICSEARCH_PORT=9200
+ELASTICSEARCH_SCHEME=http
+ELASTICSEARCH_USER=
+ELASTICSEARCH_PASS=
+ELASTICSEARCH_INDEX_NAME=pmi_staging
+
 FEATURE_QUOTE=false
 FEATURE_NEWS=false
 FEATURE_SEARCH=false
index c0c1c389c3aa25895278fbbf12317ee750f305bc..99d27502ed9e246f5a2bf82126e7bfc60cb18492 100644 (file)
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Models\News;
 use Cubist\Backpack\app\Http\Controllers\CubistFrontController;
+use Cubist\Backpack\app\Magic\PageData;
 
 class NewsController extends CubistFrontController
 {
@@ -18,6 +19,7 @@ class NewsController extends CubistFrontController
         $this->data['title'] = $newsItem->title;
         $this->data['image'] = $newsItem->getFirstMediaUrl($newsItem->image, 'thumb');
         $this->data['news'] = $newsItem;
+        $this->data['page'] = $newsItem->getPageData();
 
         return view('pages.news-detail', $this->data);
     }
index 00270900c3b462d42e2888fd964ffc0cd31907fc..3c1a6917c253871db800dadfb9045132ffcae2dd 100644 (file)
@@ -22,7 +22,7 @@ class ProductController extends CubistFrontController
         $this->data['products'] = [];
 
         $products = Product::with('media') // Eager load media to avoid N+1 query problem
-            ->where('product_type', $id)
+        ->where('product_type', $id)
             ->where('online', 1)
             ->get();
 
@@ -41,8 +41,7 @@ class ProductController extends CubistFrontController
             $this->_404();
         }
 
-        $this->data['title'] = $product->name;
-        $this->data['product'] = $product->getPageData();
+        $this->data['page'] = $this->data['product'] = $product->getPageData();
         $this->data['related'] = [];
         if (is_array($product->related) && count($product->related) > 0) {
             foreach (Product::with('media')->whereIn('id', $product->related)->limit(4)->get() as $rel) {
index 904badd72a2192338c9bd38400478481e9dd2b55..a87c8ba63af117783821868d788b6d5b37fc4781 100644 (file)
@@ -2,13 +2,13 @@
 
 namespace App\Models;
 
-use Cubist\Backpack\app\Magic\Models\CubistMagicModel;
+use Cubist\Backpack\app\Magic\Models\CubistMagicPageModel;
 use Cubist\Util\Json;
 use Illuminate\Support\Facades\App;
 use Illuminate\Support\Str;
 use Spatie\MediaLibrary\Models\Media;
 
-class Product extends CubistMagicModel
+class Product extends CubistMagicPageModel
 {
     protected static $_specifications = null;
     protected static $_productTypes = null;
@@ -59,11 +59,6 @@ class Product extends CubistMagicModel
             'column' => true,
             'tab' => 'Spécifications']);
 
-        $this->addField(['name' => 'slug',
-            'type' => 'Slug',
-            'label' => 'Slug (URL)',
-            'tab' => 'Informations génerales']);
-
         $this->addField(['name' => 'online',
             'type' => 'Checkbox',
             'label' => 'En ligne',
index 5613025601d98d5dc63fb8bde7ef15448b52a6e5..b3917e0e6d1041cd4c0572fe174c0daa4c004e79 100644 (file)
@@ -2,9 +2,9 @@
 
 namespace App\Models;
 
-use Cubist\Backpack\app\Magic\Models\CubistMagicModel;
+use Cubist\Backpack\app\Magic\Models\CubistMagicPageModel;
 
-class ProductType extends CubistMagicModel
+class ProductType extends CubistMagicPageModel
 {
     protected $table = 'catalog_product_types';
 
@@ -16,14 +16,13 @@ class ProductType extends CubistMagicModel
 
     public function setFields()
     {
+        $tab = 'Type de produit';
         $this->addField(['name' => 'name',
             'label' => 'Nom du type de produit',
             'type' => 'Text',
-            'column' => true]);
-
-        $this->addField(['name' => 'slug',
-            'label' => 'Slug',
-            'type' => 'Slug']);
+            'column' => true,
+            'tab' => $tab
+        ]);
 
         $this->addField([
                 'name' => 'type',
@@ -31,22 +30,17 @@ class ProductType extends CubistMagicModel
                 'type' => 'SelectFromArray',
                 'options' => ['captor' => 'Captor', 'system' => 'System'],
                 'column' => true,
+                'tab' => $tab,
             ]
         );
 
-        $this->addField([
-            'name' => 'intro',
-            'type' => 'BunchOfFields',
-            'bunch' => 'App\SubForms\Intro',
-            'label' => __('Introduction'),
-        ]);
-
         $this->addField(['name' => 'specifications',
             'label' => 'Spécifications',
             'type' => 'SelectFromModel',
             'optionsmodel' => "App\Models\Specification",
             'order' => true,
             'multiple' => true,
+            'tab' => 'Spécifications',
         ]);
 
         $this->addField(['name' => 'filters',
@@ -54,8 +48,19 @@ class ProductType extends CubistMagicModel
             'type' => 'SelectFromModel',
             'optionsmodel' => 'App\Models\Specification',
             'order' => true,
-            'multiple' => true]);
+            'multiple' => true,
+            'tab' => 'Spécifications',]);
+
+        $this->addField([
+            'name' => 'intro',
+            'type' => 'BunchOfFields',
+            'bunch' => 'App\SubForms\Intro',
+            'label' => __('Introduction'),
+            'tab' => 'Introduction',
+        ]);
+
 
 
+        parent::setFields();
     }
 }
index e97ef9e4b50e06f979faa9839be180e9ebe1f766..7a6569a5c372c5999ecd126d6e14bff35ac5e3c6 100644 (file)
@@ -43,6 +43,7 @@ class Aboutus extends Base
             'label' => 'Texte',
             'type' => 'Markdown',
             'tab' => 'Nos Valeurs',
+
         ]);
 
         $this->addField([
index ea8aa7ba1055af153a86578ae9423e7fa6c9a143..bf41d5950984f230ab62d198913dcef426f0c880 100644 (file)
@@ -17,7 +17,6 @@ class Base extends TemplatePage
             'label' => __('Introduction'),
             'tab' => 'Intro',
         ]);
-
     }
 
     public function showInDropDown()
index 8299bca8075bcc12883262579d5210abe7adde1c..7ed9d1b23cf0dca88e1bb9093a0f2ed3a6475a90 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 return [
+    'internal_search' => env('CUBIST_INTERNAL_SEARCH', false),
+    'internal_search_index' => env('CUBIST_INTERNAL_SEARCH_INDEX', strtolower(env('APP_NAME', 'App_name') . '_' . env('APP_ENV', 'dev'))),
     'page_model' => '\App\Models\Page',
     'settings_model' => '\App\Models\Settings',
 ];
diff --git a/config/elasticsearch.php b/config/elasticsearch.php
new file mode 100644 (file)
index 0000000..98c1ecd
--- /dev/null
@@ -0,0 +1,206 @@
+<?php
+
+return [
+
+    /**
+     * You can specify one of several different connections when building an
+     * Elasticsearch client.
+     *
+     * Here you may specify which of the connections below you wish to use
+     * as your default connection when building an client. Of course you may
+     * use create several clients at once, each with different configurations.
+     */
+
+    'defaultConnection' => 'default',
+
+    /**
+     * These are the connection parameters used when building a client.
+     */
+
+    'connections' => [
+
+        'default' => [
+
+            /**
+             * Hosts
+             *
+             * This is an array of hosts that the client will connect to. It can be a
+             * single host, or an array if you are running a cluster of Elasticsearch
+             * instances.
+             *
+             * This is the only configuration value that is mandatory.
+             *
+             * Presently using "extended" host configuration method
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_extended_host_configuration
+             *
+             * There is also the shorter "inline" configuration method available
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_inline_host_configuration
+             */
+
+            'hosts' => [
+                [
+                    'host'       => env('ELASTICSEARCH_HOST', '127.0.0.1'),
+                    'port'       => env('ELASTICSEARCH_PORT', 9200),
+                    'scheme'     => env('ELASTICSEARCH_SCHEME', null),
+                    'user'       => env('ELASTICSEARCH_USER', null),
+                    'pass'       => env('ELASTICSEARCH_PASS', null),
+
+                    // If you are connecting to an Elasticsearch instance on AWS, you will need these values as well
+                    'aws'        => env('AWS_ELASTICSEARCH_ENABLED', false),
+                    'aws_region' => env('AWS_REGION', ''),
+                    'aws_key'    => env('AWS_ACCESS_KEY_ID', ''),
+                    'aws_secret' => env('AWS_SECRET_ACCESS_KEY', '')
+                ],
+            ],
+
+            /**
+             * SSL
+             *
+             * If your Elasticsearch instance uses an out-dated or self-signed SSL
+             * certificate, you will need to pass in the certificate bundle.  This can
+             * either be the path to the certificate file (for self-signed certs), or a
+             * package like https://github.com/Kdyby/CurlCaBundle.  See the documentation
+             * below for all the details.
+             *
+             * If you are using SSL instances, and the certificates are up-to-date and
+             * signed by a public certificate authority, then you can leave this null and
+             * just use "https" in the host path(s) above and you should be fine.
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_security.html#_ssl_encryption_2
+             */
+
+            'sslVerification' => null,
+
+            /**
+             * Logging
+             *
+             * Logging is handled by passing in an instance of Monolog\Logger (which
+             * coincidentally is what Laravel's default logger is).
+             *
+             * If logging is enabled, you either need to set the path and log level
+             * (some defaults are given for you below), or you can use a custom logger by
+             * setting 'logObject' to an instance of Psr\Log\LoggerInterface.  In fact,
+             * if you just want to use the default Laravel logger, then set 'logObject'
+             * to \Log::getMonolog().
+             *
+             * Note: 'logObject' takes precedent over 'logPath'/'logLevel', so set
+             * 'logObject' null if you just want file-based logging to a custom path.
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#enabling_logger
+             */
+
+            'logging' => false,
+
+            // If you have an existing instance of Monolog you can use it here.
+            // 'logObject' => \Log::getMonolog(),
+
+            'logPath' => storage_path('logs/elasticsearch.log'),
+
+            'logLevel' => Monolog\Logger::INFO,
+
+            /**
+             * Retries
+             *
+             * By default, the client will retry n times, where n = number of nodes in
+             * your cluster. If you would like to disable retries, or change the number,
+             * you can do so here.
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_set_retries
+             */
+
+            'retries' => null,
+
+            /**
+             * The remainder of the configuration options can almost always be left
+             * as-is unless you have specific reasons to change them.  Refer to the
+             * appropriate sections in the Elasticsearch documentation for what each option
+             * does and what values it expects.
+             */
+
+            /**
+             * Sniff On Start
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html
+             */
+
+            'sniffOnStart' => false,
+
+            /**
+             * HTTP Handler
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_configure_the_http_handler
+             * @see http://ringphp.readthedocs.org/en/latest/client_handlers.html
+             */
+
+            'httpHandler' => null,
+
+            /**
+             * Connection Pool
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_connection_pool
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_connection_pool.html
+             */
+
+            'connectionPool' => null,
+
+            /**
+             * Connection Selector
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_connection_selector
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_selectors.html
+             */
+
+            'connectionSelector' => null,
+
+            /**
+             * Serializer
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_serializer
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_serializers.html
+             */
+
+            'serializer' => null,
+
+            /**
+             * Connection Factory
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_a_custom_connectionfactory
+             */
+
+            'connectionFactory' => null,
+
+            /**
+             * Endpoint
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/6.0/_configuration.html#_set_the_endpoint_closure
+             */
+
+            'endpoint' => null,
+
+
+            /**
+             * Register additional namespaces
+             *
+             * An array of additional namespaces to register.
+             *
+             * @example 'namespaces' => [XPack::Security(), XPack::Watcher()]
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/ElasticsearchPHP_Endpoints.html#Elasticsearch_ClientBuilderregisterNamespace_registerNamespace
+             */
+            'namespaces' => [],
+
+            /**
+             * Tracer
+             *
+             * Tracer is handled by passing in a name of the class implements Psr\Log\LoggerInterface.
+             *
+             * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_a_custom_connectionfactory
+             */
+            'tracer' => null,
+
+        ],
+
+    ],
+
+];