From 635af0b7c104f4696a125443f6c63fd75e1ca1b1 Mon Sep 17 00:00:00 2001 From: vikram chand Date: Thu, 4 Mar 2021 18:50:33 +0530 Subject: [PATCH] Updated: createSampleField method --- Http/Middleware/SetContent.php | 2 +- Libraries/CmsSeeder.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Http/Middleware/SetContent.php b/Http/Middleware/SetContent.php index 432f7c4..cd6f29b 100644 --- a/Http/Middleware/SetContent.php +++ b/Http/Middleware/SetContent.php @@ -26,7 +26,7 @@ public function handle(Request $request, Closure $next) $permalink = $request->segment(2); - if(isset($content_type) || !isset($permalink)) + if(isset($content_type) && !isset($permalink)) { $permalink = $content_type; $content_type = 'pages'; diff --git a/Libraries/CmsSeeder.php b/Libraries/CmsSeeder.php index 5f22b97..ca9268c 100644 --- a/Libraries/CmsSeeder.php +++ b/Libraries/CmsSeeder.php @@ -210,7 +210,7 @@ public static function contentTypes($file_path) } } //------------------------------------------------------- - public static function pages($theme_slug, $file_path) + public static function createSampleField($theme_slug, $file_path, $content_type_slug = 'pages') { $theme = self::getTheme($theme_slug); @@ -230,7 +230,7 @@ public static function pages($theme_slug, $file_path) return false; } - $content_type = ContentType::where('slug', 'pages') + $content_type = ContentType::where('slug', $content_type_slug) ->with(['groups.fields.type']) ->first()->toArray(); @@ -252,6 +252,10 @@ public static function pages($theme_slug, $file_path) continue; } + if(!isset($item['slug']) || !$item['slug']){ + $item['slug'] = Str::slug($item['name']); + } + $page = Content::where('slug', $item['slug']) ->where('vh_cms_content_type_id', $content_type['id']) ->where('vh_theme_id', $theme->id)