]> _ Git - cubist_cms-back.git/commitdiff
wip #3080 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Sep 2019 14:24:38 +0000 (16:24 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Sep 2019 14:24:38 +0000 (16:24 +0200)
src/app/Magic/Models/CubistMagicAbstractModel.php
src/app/Magic/Models/CubistMagicTranslatableModel.php
src/app/Magic/Models/Locale.php
src/app/Middleware/LocaleSelector.php [new file with mode: 0644]
src/resources/config/cubist.php

index a6fb6c91c7ca50f928c6bcce6943efd3ab8ca8f6..63e4fdf1f314e635ac349e1344bae14338333f45 100644 (file)
@@ -25,8 +25,6 @@ use Venturecraft\Revisionable\RevisionableTrait;
 class CubistMagicAbstractModel extends Model implements HasMedia
 {
     use CrudTrait;
-    use Sluggable;
-    use SluggableScopeHelpers;
     use HasMediaTrait;
     use RevisionableTrait;
     use BunchOfFields {
index 71384de83201aacac1ef5602f951eb1f9d545431..9eaa0488b6018e633c1982940c75c6c3246ea19b 100644 (file)
@@ -9,8 +9,6 @@ use Backpack\CRUD\ModelTraits\SpatieTranslatable\SluggableScopeHelpers;
 
 class CubistMagicTranslatableModel extends CubistMagicAbstractModel
 {
-    use Sluggable;
-    use SluggableScopeHelpers;
     use HasTranslations {
         update as protected updateTranslations;
         create as protected createTranslations;
index 2fbe7299b9d7962a31f82aa9b7b577a2cbc0b193..febc19fa82d61a310cc8e0d7f3bbb10de19126a8 100644 (file)
@@ -46,4 +46,14 @@ class Locale extends CubistMagicAbstractModel
             'translatable' => false,
         ]);
     }
+
+    public static function getLocaleClass()
+    {
+        $class = self::class;
+        $config = config('cubist.locale_model', 'Cubist\Backpack\app\Magic\Models\Locale');
+        if (class_exists($config)) {
+            $class = $config;
+        }
+        return $class;
+    }
 }
diff --git a/src/app/Middleware/LocaleSelector.php b/src/app/Middleware/LocaleSelector.php
new file mode 100644 (file)
index 0000000..25c97bd
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace Cubist\Backpack\app\Middleware;
+
+use Cubist\Backpack\app\Magic\Models\Locale;
+use Illuminate\Http\Request;
+
+class LocaleSelector
+{
+    public function handle(Request $request, Closure $next)
+    {
+        $response = $next($request);
+        // No need to change locale depending on the domaine on admin
+        if (strpos($request->getPathInfo(), '/admin/') === 0) {
+            return $response;
+        }
+
+        $domain = $request->getHttpHost();
+        $class = Locale::getLocaleClass();
+
+        $locales = $class::where('active', 1)->get(0);
+        foreach ($locales as $locale) {
+            dd($locale);
+        }
+
+        return $response;
+    }
+}
index a231e8de273743257302693e29b383d3105976fc..fe62b905db6bd9da1309088df87e0c779e8c6cac 100644 (file)
@@ -5,5 +5,6 @@ return [
     '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',
+    'locale_model' => '\App\Models\Locale',
     'seo_robots' => env('SEO_ROBOTS', true),
 ];